求一个数据转换办法
select Services from dbo.Contract
查询结果如下
8.844
123.2009
176.7991
423.0
573.0
80.0
13.6422
4.059
18.612
5.0
192.0
165.0
11.589554
2008.49
现在该字段为varchar
我数据最多有null的出现,我想把该字段强制转换成numeric,小数点保留4位,直接数据库无法转换,怎么才能将字段转换过来?
[解决办法]
是什么数据库?发帖前看置顶标题了吗?
[解决办法]
select cast(Services as float) as Services from dbo.Contract
where isnumeric(Services)=1 and Services not like '%[^0-9]%' and Services is not null