June 26, 2007 at 8:38 am
Hi
I want to be able to pass a parameter into a stored procedure which takes the form ('ABC', 'DEF', 'GHI') so that I can use the following and get a sensible answer out of it:
Select * from table1 where field1 in @param1
Where @param1 contains the string in brackets above. I must be slightly brain-dead but no matter what I try I either get an error or nothing.
Can anyone help please ?
Thanks
Dan
June 26, 2007 at 9:51 am
Thanks mrpolecat I'll give it a go. I think I'll run into other problems, because I want to use the select statement as part of a cursor (I've heard I shouldn't be using these, but they're very handy :-))
June 26, 2007 at 9:57 am
June 26, 2007 at 10:02 am
also search for the Split() function in the scripts...there are several, and some return a table with multiple columns (ELEMENT,ELEMENTID), some just return a single column, etc. the split a string on a specified delimiter, like a comma.
you can pass the values to the split function and do something like this:
elect * from table1 where field1 in (select ELEMENT from dbo.Split(@param1,,',') )
Lowell
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply