question

natongm avatar image
natongm asked

How do I Split pipe delimited Values into Separate Columns?

I am trying to split RADIO_COMBO column which has a several pipe delimited values into separate columns, so I will end up with RADIO_COMBO1, RADIO_COMBO2, etc Below is the simplified code: SELECT SALESPERSON, CALL_LETTERS, right(ZONE_LIST,4) as ZONE, RADIO_COMBO FROM Survey Below is the sample output for the column: 7133 6202 7287 6221 |-1.000÷4|CMDY-TV CNN -TV ESP2-TV SPK -TV|MTMEN3GBº|133
delimited-string
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KenJ avatar image
KenJ answered
The problem has been covered numerous times on this site. Here are a few previous questions/answers that may get you going (I think the second link probably has exactly what you're looking for): [ http://ask.sqlservercentral.com/questions/105789/i-have-one-column-its-having-aaaaaaabbbaabaac-valu.html][1] [ http://ask.sqlservercentral.com/questions/90968/how-do-i-extract-data-from-a-variable-length-delim.html][2] [ http://ask.sqlservercentral.com/questions/23117/how-has-splitting-a-delimited-string-improved-sinc.html][3] There are quite a few answers to similar questions under the delimited-string tag that you might find useful, too - [ http://ask.sqlservercentral.com/questions/topics/delimited-string.html?sort=active&pageSize=50][4] For external resources, there is a great article by Jeff Modern on splitting delimited strings with a tally table here (with sample code) - [ http://www.sqlservercentral.com/articles/T-SQL/62867/][5] Erland Sommarskog also has an exhaustive analysis of various string splitting approaches - [ http://www.sommarskog.se/arrays-in-sql-2005.html][6] and [ http://www.sommarskog.se/arrays-in-sql.html][7] [1]: http://ask.sqlservercentral.com/questions/105789/i-have-one-column-its-having-aaaaaaabbbaabaac-valu.html [2]: http://ask.sqlservercentral.com/questions/90968/how-do-i-extract-data-from-a-variable-length-delim.html [3]: http://ask.sqlservercentral.com/questions/23117/how-has-splitting-a-delimited-string-improved-sinc.html [4]: http://ask.sqlservercentral.com/questions/topics/delimited-string.html?sort=active&pageSize=50 [5]: http://www.sqlservercentral.com/articles/T-SQL/62867/ [6]: http://www.sommarskog.se/arrays-in-sql-2005.html [7]: http://www.sommarskog.se/arrays-in-sql.html
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you KenJ!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.