SQL Server - In clause with a declared variable
Posted
by Melursus
on Stack Overflow
See other posts from Stack Overflow
or by Melursus
Published on 2010-05-31T15:34:46Z
Indexed on
2010/05/31
15:53 UTC
Read the original article
Hit count: 272
Let say I got the following :
DECLARE @ExcludedList VARCHAR(MAX)
SET @ExcludedList = 3 + ', ' + 4 + ' ,' + '22'
SELECT * FROM A WHERE Id NOT IN (@ExcludedList)
Error : Conversion failed when converting the varchar value ', ' to data type int.
I understand why the error is there but I don't know how to solve it...
© Stack Overflow or respective owner