May 10, 2010 at 4:27 pm
I came across an article on the forum written by Jeff Moden about using tally tables to split delimited. I have implemented this in numerous instances and found the benefits in terms of performance.
Is it possible to extend the use of the tally table to split strings which contain different delimiters?
eg
split '456|wewed,ewewewe,wewewfrfr;f123221;wewewewe/eererewrwe/'
to
456 wewed ewewewe wewewfrfr f123221 wewewewe eererewrwe
May 10, 2010 at 6:20 pm
eseosaoregie (5/10/2010)
I came across an article on the forum written by Jeff Moden about using tally tables to split delimited. I have implemented this in numerous instances and found the benefits in terms of performance.Is it possible to extend the use of the tally table to split strings which contain different delimiters?
eg
split '456|wewed,ewewewe,wewewfrfr;f123221;wewewewe/eererewrwe/'
to
456 wewed ewewewe wewewfrfr f123221 wewewewe eererewrwe
Yep... you can simply do a series of nested replaces (very fast, by the way) to make all the delimiters the same. For example...
SELECT REPLACE(
REPLACE(
REPLACE(
'456|wewed,ewewewe,wewewfrfr;f123221;wewewewe/eererewrwe/'
,'|',',')
,';',',')
,'/',',')
--Jeff Moden
Change is inevitable... Change for the better is not.
May 11, 2010 at 12:02 am
Thanks. I wil give this a go.
May 11, 2010 at 6:25 am
You bet... thank you for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 18, 2010 at 5:58 am
That seemed to work. I just had to add a PIVOT clause to reformat the data.
May 18, 2010 at 7:23 am
Very cool. Thanks for the time to make a feedback. If you get the chance, post your code so folks can see what you've done with PIVOT.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply