将 varchar 值转换为数据类型为 int 的列时发生语法错误
在写一个存储过程逗sql语句 其中@gx_id 为int
set @strSql = 'update scpc_detail set '+ @updatefiled + '='''+ @updatetext + ''' where '
+ ' h_guid =''' + @guid + ''' and gongxu_id =' + @gx_id;
exec(@strSql);
一执行就报 将 varchar 值转换为数据类型为 int 的列时发生语法错误,找了好久,问了同事才知道问题出在哪
我这是在逗sql语句,当然都是用字符串逗了,@gx_id 为数字。
解决办法:把@gx_id转为字符串。
大家可以在查询分析器中 试一下 print 'as' + 1 这个,就明白了 print 'as' + str(1);
学习,积累中......
浙公网安备 33010602011771号