您的位置:首页 > 数据库

sql 将 varchar 值转换为数据类型为 int 的列时发生语法错误 的解决办法

2007-09-10 17:13 1051 查看
group表有个varchar 的字段groupPower,值为1,2,3,4,有个sql语句为

select * from dbo.function where

functionId in

(

select groupPower from dbo.group

where groupid=1

)

执行出错将 varchar 值 '1,2,3,4' 转换为数据类型为 int 的列时发生语法错误。

解决方法:

将where 条件改为:

where charindex(rtrim(functionId), (select top 1 groupPower from loan_group where groupid=1 ))>0

就ok了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐