读书人

float 转换为字符显示,该怎么处理

发布时间: 2012-05-23 13:44:13 作者: rapoo

float 转换为字符显示
一个表里的字段为float类型,值为-1.1的想查询后显示为字符:abc

(case col when -1.1 then 'abc' else col end) as col

这么写的话会提示:从数据类型 varchar 转换为 float 时出错.
有什么好的方法把float转换为字符吗?

[解决办法]

SQL code
(case ltrim(col) when '-1.1' then 'abc' else ltrim(col) end) as col 

读书人网 >SQL Server

热点推荐