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

论坛 期权论坛 脚本     
匿名技术用户   2020-12-28 10:45   38   0
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了

转载于:https://www.cnblogs.com/kevinlzf/archive/2007/09/10/888707.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP