求一个数据转换办法

shan__le 2010-08-05 11:17:34
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位,直接数据库无法转换,怎么才能将字段转换过来?
...全文
70 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
oO寒枫Oo 2010-08-25
  • 打赏
  • 举报
回复

select cast(Services as float) as Services from dbo.Contract
where isnumeric(Services)=1 and (Services not like '%[^0-9]%' or charindex('.',EncDataText)>1 ) and Services is not null
oO寒枫Oo 2010-08-25
  • 打赏
  • 举报
回复
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
iihero 2010-08-07
  • 打赏
  • 举报
回复
是什么数据库?发帖前看置顶标题了吗?
shan__le 2010-08-05
  • 打赏
  • 举报
回复
有没有人回答啊?还是无法解决?

2,598

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧