将varchar列值的结果转换为逗号deligma int类型

时间:2014-05-06 11:48:37

标签: sql-server-2008-r2

SQL语句:

(select top 1 [egrp_name] from [Enotify Group] where [egrp_id] in (a.grp_id) )

a.grp_id的值为'0,1145',我收到错误

Conversion failed when converting the varchar value '0,1145' to data type int.

有人可以告诉我如何在上述情况下将'0,1145'更改为0,1145

1 个答案:

答案 0 :(得分:0)

select top 1 [egrp_name] 
from [Enotify Group] 
where [egrp_id] in (cast(replace(grp_id, ',', '.') as decimal))