Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 using the IN statement

Author  Topic 

matt_calhoon
Posting Yak Master

235 Posts

Posted - 2001-09-13 : 22:39:41
Hi There,

I have a stored procedure that needs to accept multiple integer values seperated by a comma "," (for eg 1,2,4,78) and then do a search on a table using the IN statement which grabs all records with the supplied IDs. The problem I have is that how do you call this from ASP without having to convert the values "1, 2, 4, 78" to a nvarchar?

eg;
IntIDS = "1, 2, 4, 78"
calling stored proc:
conn.execute("P_SELECT_SOMETHING [" & IntIDS & "]"

stored proc:
CREATE PROCEDURE P_SELECT_SOMETHING

@CATID = int

AS
Select * FROM MYTABLE WHERE ID IN (@CATID)

now obviously this wont work because it cant convert the string value containing commas to a datatype int.

Just would like to know the best way to do this - I have a couple ideas but as usual they are pretty stupid!

cheers - matt


   

- Advertisement -