Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Looping Comma separated string Expand / Collapse
Author
Message
Posted Tuesday, October 22, 2013 7:28 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:59 PM
Points: 13,007, Visits: 12,426
SrcName (10/22/2013)
declare @input varchar(50)='100,200,300,400,500'

select '1', q2.value from
( SELECT cast('<x>'+replace(@input,',','</x><x>')+'</x>' as xml) as txml ) q1 CROSS APPLY
( SELECT x.value('.','varchar(100)') as value FROM txml.nodes('x') as f(x) )q2


You too should have a read of that article. In case you missed it, you can find it in my signature too. The article about splitting strings. It is a serious mind opening read.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1507126
Posted Tuesday, October 22, 2013 7:32 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, April 9, 2014 11:31 AM
Points: 175, Visits: 351
Hello Ed Wagner,

I totally agree that "DelimitedSplit8K" function is much faster. thanks for your time.
Post #1507133
Posted Tuesday, October 22, 2013 8:40 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 1:48 PM
Points: 4,053, Visits: 3,490
born2achieve (10/22/2013)
Hello Ed Wagner,

I totally agree that "DelimitedSplit8K" function is much faster. thanks for your time.

No problem - glad I could help. I cannot, however, take any credit for coming up with DelimitedSplit8K. That credit goes to Jeff Moden.



Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Post #1507188
Posted Tuesday, October 22, 2013 12:25 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, April 9, 2014 11:31 AM
Points: 175, Visits: 351
Yes i agree that credit goes to Jeff.

by the way, i am good with insert statement. Any suggestion with update statement? how can i update the sample table with the out come of funtion returns table? any suggestions please
Post #1507283
Posted Wednesday, October 23, 2013 5:09 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, April 9, 2014 11:31 AM
Points: 175, Visits: 351
can any one please suggest me
Post #1507543
Posted Wednesday, October 23, 2013 7:39 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:59 PM
Points: 13,007, Visits: 12,426

Any suggestion with update statement? how can i update the sample table with the out come of funtion returns table?


You need to provide us a bit more detail here. What does that mean?


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1507623
Posted Wednesday, October 23, 2013 8:02 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, April 9, 2014 11:31 AM
Points: 175, Visits: 351

sorry for the confusion. i am done with my requirement. thanks for your time.
Post #1507631
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse