SyntaxFix
Write A Post
Hire A Developer
Questions
You need to execute this as a dynamic sp like
DECLARE @ExcludedList VARCHAR(MAX) SET @ExcludedList = '3,4,22,6014' declare @sql nvarchar(Max) Set @sql='SELECT * FROM [A] WHERE Id NOT IN ('+@ExcludedList+')' exec sp_executesql @sql