March 4, 2009 at 10:55 am
Hi All
I have created a SP that accepts a variable as input, can i pass multiple values SP the SP returns result for all
EXEC SPNAME 'SAM'
Say the above SP returns details about SAM, can i get details for SAM and Andy using the same SP, by passing 2 values into the SP
is this possible ??
Please suggest me 🙂
March 4, 2009 at 11:25 am
typically, you might pass a comma delimited string to the procedure, and the proc then uses one of the many SPLIT functions in the Scripts section here on SSC to turn teh comma delimited list into a table;
exec sp_yourproc('Bill,Andy,Doug,Bob)
which does something like SELECT FROM USERS WHERE USERNAME IN (SELECT ELEMENT FROM dbo.Split(@CommaDelimitedlist,',') )
Lowell
March 4, 2009 at 11:34 am
Thanks Lowell, that's a nice plan :), will try that one
March 4, 2009 at 12:20 pm
You could also use dynamic sql to do this.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply