我使用的是MSSQL EXPRESS 2008年,我试图来连接记录的ID列与它的使用下面的查询串联int和nvarchar列
SELECT CAST(GotoviProizvodi.ID as nvarchar(4)) + ' - ' + CAST(GotoviProizvodi.Opis as nvarchar(max)) AS Opis
FROM GotoviProizvodi,Recept
WHERE [email protected]
AND Recept.Proizvod=GotoviProizvodi.Opis
GotoviProizvodi.ID is defined in the schema as int -- the ID column
GotoviProizvodi.Opis is defined as nvarchar(200) -- the description column
但说明列,当我尝试执行它产生此查询:
消息245,级别16,状态1,过程GetProizvodByReceptId,第2行转换 转换nvarchar的值“测试”为数据类型int时失败。
为什么它试图将它转换为int,当我明确地告诉它将其转换为nvarchar?任何解决方法?
是什么'Recept.Proizvod'的数据类型的连接? – Taryn
“@ ID”的数据类型是什么? – garyh