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 2005 Forums
 Transact-SQL (2005)
 Splitting string to use in WHERE

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2007-09-26 : 04:20:39
I've got a table with category names and id's

Then in a second table i've got product names and a field for category id's, this is in the format :1:23:4:56 - i.e. this product is in categories 1, 23, 4 and 56.

I need to do somthing like this

SELECT * FROM products WHERE categoryID IN (SELECT cateogryID FROM categories WHERE type=1)

But I need to split the :1:23:4:56 into 1, 23, 4, 56 and select where any of those cateogries are in that subquery.

Thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-09-26 : 04:31:17
Check some of the split functions listed here:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

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

- Advertisement -