The following code sends error.
@resp2 is INT, it’s the result of a sum preiously done. So now I want to update some row in another table using a dinamic statement.
SET @SQL = 'update TelepromTableNamesInfo set [Resp] = '+@RESP2+'
where nombre = ''' + @TableWBraq + ''''
EXEC (@SQL)
First thing I’ve tried is ”’+@resp2+”’ But I don’t want it be
‘ variable value ‘
since it’s an INT value and there’s no need for ”
The error makes sence. I can’t put some INT value into a string. I’d use cast or convert but how can I do it inside the statement?
Or maybe I’m approaching the update from the wrong perspective?
Thanks.
EDIT
Solved.
'+ cast(@RESP2 as nvarchar(7))+'
It was easier than I thought, thanks.
1 Answer