以下是我的查詢和錯誤。當我把VARCHAR變量和通過INT值,然後我得到錯誤。將VARCHAR數據和搜索INT值取得錯誤
查詢:
declare @vid VARCHAR(MAX)
set @vid= ('3,5,7')
Select (Stuff((Select ', ' + VehicleClassName
From VehicleClass_Master
where VehicleClassId in (@VID) FOR XML PATH('')),1,2,''))
錯誤:
Msg 245, Level 16, State 1, Line 3 Conversion failed when converting the varchar value '3,5,7' to data type int.
可能重複https://stackoverflow.com/q/337704/1048425 – GarethD