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)
 String Manipulation and Sub Query

Author  Topic 

ernie99
Starting Member

12 Posts

Posted - 2009-03-25 : 08:04:25
Hi everyone,

I have a column called 'Parents' that contains a string of Parent Categories separated by a | character e.g. |0|295|297|301|

I need to dynamically generate a column that contains the description value for each category in this string separated by a / character e.g. /News/Investors/About Us/Resource Library/

Therefore on the fly I have to extract each Category from the column 'Parents' and select the value of the column 'Description' for that Category.

An example result set would look like the following

--------------------------------------------------------------
CATEGORIES
--------------------------------------------------------------
CAT_ID-----DESCRIPTION----------PARENTS----------PARENT_DESCRIPTION
312--------Home-----------------|0|295|----------News/Investors
295--------Investors------------|0|312|----------News/Home
308--------About Us-------------|0|295|312|------News/Investors/Home

If anyone can help me get started on this I would greatly appreciate it.

Thanks to anyone who views this post.


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-25 : 08:13:53
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

ernie99
Starting Member

12 Posts

Posted - 2009-03-25 : 09:55:31
That's for the advice, much appreciated.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-25 : 14:07:33
why are you storing parent id values in delimited form? why is your table not normalised?
Go to Top of Page
   

- Advertisement -