Gossamer Forum
Home : General : Databases and SQL :

Help...Passing CSVs to a procedure for with IN...how?

Quote Reply
Help...Passing CSVs to a procedure for with IN...how?
Hoping someone can help.....

I have a procedure and I want the @acceptIDs and @banIDs arguments to be able to accept CSVs, using a statement in ASP like:

rsUsers.Open("sp_GetMailList '5,32', '1,12'", adoConn, 3, 1)

Currently I have them both arguments to the procedure set as varchars but this doesn't work as each item inthe CSVs are numeric and only the first item is used in the IN expressions. Can someone help me fix this problem; am I approaching this right....thanks in advanced.

CREATE PROCEDURE sp_GetResults
@acceptIDs varchar, @banIDs varchar
AS

SELECT *
FROM tableA
WHERE fieldNameA IN (@acceptIDs) AND fieldNameA NOT IN (@banIDs)

GO