Something regarding NOT IN | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Something regarding NOT IN

Hi, i want to compare a column data with a list of string, and this string actually already predefined in a variable. for example set @skipcolDef = @skipcol + ”’TEST”,”TEST1”’ SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ‘SAMPLE’ AND COLUMN_NAME NOT IN (@skipcolDef) where @skipcol is a variable pass in when execute stored procedure. example above when execute through query analyser it return execute successfully but with wrong result. Actually how should i do for this case?

You might want to read this<a target="_blank" href=http://www.sommarskog.se/dynamic_sql.html>http://www.sommarskog.se/dynamic_sql.html</a> . It explains why this doesn’t work. <br />And then<a target="_blank" href=http://www.sommarskog.se/arrays-in-sql.html>http://www.sommarskog.se/arrays-in-sql.html</a> how you can make it work.<br />[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br /><br />–Frank<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by FrankKalis</i><br /><br />You might want to read this<a target="_blank" href=http://www.sommarskog.se/dynamic_sql.html>http://www.sommarskog.se/dynamic_sql.html</a> . It explains why this doesn’t work. <br />And then<a target="_blank" href=http://www.sommarskog.se/arrays-in-sql.html>http://www.sommarskog.se/arrays-in-sql.html</a> how you can make it work.<br />[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br /><br />–Frank<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br /><br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />Thank you!<br />[<img src=’/community/emoticons/emotion-2.gif’ alt=’:D‘ />]
]]>