August 22, 2008 at 2:31 pm
Any ideas on how to parse one column into 4 columns where the on column has a sting value like: \ Application \ Microsoft Office \ Word \ Error
Thank you,
ATW
August 22, 2008 at 3:01 pm
There is a great function here - http://www.sommarskog.se/arrays-in-sql-2005.html that works well and I'm sure you could tweak it to charindex on the "/" rather than comma's. If this is a one off then you could work through his code as well to get your answer.
David
@SQLTentmaker“He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot
August 24, 2008 at 11:44 pm
I think that this is a much easier way:
Select Parsename(strg,4)
, Parsename(strg,3)
, Parsename(strg,2)
, Parsename(strg,1)
From (
Select Replace(
Replace('\ Application \ Microsoft Office \ Word \ Error ',' \ ','.')
, '\ ', '') as strg) A
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
August 25, 2008 at 9:13 am
It looks like that might work, except I have some rows that only have three values. i.e., \ Application \ Microsoft Office \ Install which causes strg4 to be Null and puts Application in strg3 column. I would always need to have Application be column1 (i.e., Application). Any ideas on resolving that issue?
Thank you all for the help.
ATW
August 25, 2008 at 10:59 am
You'll probably want to go with one of the more general "Split" methods then.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply