you cant pass a variable to in. for achieveing this you can do either of below1. use a parse function to parse the comma seperated list and make it table of values and join to it like belowdeclare @site nvarchar(500)select @site='256,122'SELECT u.*FROM users uINNER JOIN dbo.ParseString(@site,',') fON f.Val= u.sitecode
ParseString can be found in below linkhttp://visakhm.blogspot.com/2010/02/parsing-delimited-string.html2. Another way is to regard it as string and do a string comparison using like as belowdeclare @site nvarchar(500)select @site='256,122'select * from users where ',' + @site + ',' LIKE '%,' + cast(sitecode as varchar(10)) + ',%'
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/