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
 Transact-SQL (2000)
 Treating a string as code

Author  Topic 

marsh_1st
Starting Member

1 Post

Posted - 2007-05-23 : 07:16:02
I am new to this forum but i have a probably very simple question.

My senerio is this. The user will call an sp with an unknown number of arguments so i have decided to make this a single argument which is a concatination of all the arguments eg. "'cat', 'dog', 'cow'". Is there a simple way of getting this string passed as code inside an IN or similar.

So, for example, the above string is called @variable. Is there a way of doing something like ..... IN (SELECT @variable) such that it is equivalent to ...... IN ('cat', 'dog', 'cow')

Any help would be appreciated

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-23 : 07:36:54

http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2007-05-23 : 08:10:39
Hi,

if u r table is small, then u can try something like
select * from tblname where ',' + @variable + ',' like '%,' + colname + ',%'

else use splitfunction, which u can search in this forum.
Go to Top of Page
   

- Advertisement -