日期:2014-05-17  浏览次数:20494 次

求助: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+')')