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)
 split function and dynamic sql

Author  Topic 

Babli
Yak Posting Veteran

53 Posts

Posted - 2007-01-29 : 05:47:42
Hi,

I need to build a query in my stored procedure like this

SELECT * FROM TABLE
WHERE
Col1 like '%abc%'
AND Col1 like '%xyz%'
AND Col1 like '%123%'

The clause after the "WHERE" condition will be dynamic based on the variable
@varDyn = 'abc,xyz,123'

So I need to split the above variable by comma and frame the sql query.

Help needed.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-29 : 05:52:38
There are various split functions posted and described here:
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-01-29 : 08:48:39
... and some associated reading here:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=CSV,Splitting%20delimited%20lists,Best%20split%20functions

Kristen
Go to Top of Page
   

- Advertisement -