当前位置: 代码迷 >> Sql Server >> in(@参数)报错:在将nvarchar值转换成数据类型int时失败
  详细解决方案

in(@参数)报错:在将nvarchar值转换成数据类型int时失败

热度:689   发布时间:2016-04-24 23:33:13.0
求助:in(@参数)报错:在将nvarchar值转换成数据类型int时失败
本帖最后由 daisyding1984 于 2013-02-23 10:03:29 编辑
select * from GoodsAttr where AttrId = @AttrId and GoodsAttrId in (@GoodsAttrId)
报错:在将nvarchar 值 转换成数据类型 int 时失败

然后改成:
exec('select * from GoodsAttr where AttrId = @AttrId and GoodsAttrId in ('+@GoodsAttrId+')')
报错:必须声明标量变量 "AttrId"

求助改怎么写?(字段AttrId是Int类型)

------解决方案--------------------
exec('select * from GoodsAttr where AttrId ='+ @AttrId +' and GoodsAttrId in ('+@GoodsAttrId+')')
  相关解决方案