Jeff writes "Okay, I think this one's pretty tough. I'm a pretty good query writer and this one's had me stumped for a long time...On our site we allow the users to select products from a list of checkboxes. Those ProductIds are then passed to a stored procedure which returns products corresponding to the checked product ids. When I pass in the product ids and use them in the query, it returns no records. When I use the product ids and create a string which I then EXECUTE, I get results.If you execute the following queries you will see the problem.Thanks for your help.--Jeffp.s. Windows 2000 Server, SQL Server 2000USE NorthwindGO/* A straight query works */SELECT ProductName FROM Products WHERE ProductId IN (1,2,3)GO/* or */SELECT ProductName FROM Products WHERE CAST(ProductId As VarChar(5)) IN ('1','2','3')GO/* Creating a string and then using EXEC to execute the string works */CREATE PROC GetProductsString (@ProductIds varchar(100))AS DECLARE @s VarChar(500) SET @s = 'SELECT ProductName FROM Products WHERE CAST(ProductId As VarChar(5)) IN (' + @ProductIds + ')' EXEC (@s)GOEXEC GetProductsString '1,2,3'GO/* But using the product ids in a "raw" query doesn't work */CREATE PROC GetProducts (@ProductIds varchar(100))AS -- this didn't work either --SET @ProductIds = '''' + REPLACE(@ProductIds, ',', ''',''') + '''' SELECT ProductName FROM Products WHERE CAST(ProductId As VarChar(5)) IN (@ProductIds)GOEXEC GetProducts '1,2,3'GO"