读书人

in(@参数)报错:在将nvarchar值转换成

发布时间: 2013-03-01 18:33:02 作者: rapoo

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

读书人网 >SQL Server

热点推荐