子风.NET 进阶中......

路途多艱,唯勤是岸

 

将 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);

posted on 2009-01-06 11:27  子风  阅读(2697)  评论(2)    收藏  举报

导航