sql“数据类型varbinary和varchar在add运算符中不兼容。”

时间:2016-08-28 20:56:51

标签: mysql sql sql-server

   update UserData set strItem = cast( substring(strItem, 1, @i) + cast(cast(@Cdwid as varchar(4)) + @Cdur + @Cstack as varchar(8)) + substring(strItem, @i+8, 401-@i) as binary(400)) where strUserID = @strUserID``

和错误

The data types varbinary and varchar are incompatible in the add operator.

我做错了什么?

感谢...

编辑---------------------

感谢你的ansver,我解决了这个问题,我没有将strItem(二进制)转换为字符串(varchar)。

新代码:

 update UserData set strItem = cast( substring(cast(strItem as varchar(4)), 1, @i) + cast(cast(@Cdwid as varchar(4)) + @Cdur + @Cstack as varchar(8)) + substring(cast(strItem as varchar(4)), @i+8, 401-@i) as binary(400)) where strUserID = @strUserID

0 个答案:

没有答案