question

programmher avatar image
programmher asked

Splitting comma delimited results into rows from XL

SELECT CData.value('(/fields/Genres)[1]', 'varchar(255)')FROM Categories WHERE ReqNum = 9281 Here are my results: King, Saul, Robb I need the results to display like this: King Saul Robb How do I modify my script so my results display in rows instead of the comma delimited fields?
sqlxmlcomma-delimited
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

·
Grant Fritchey avatar image
Grant Fritchey answered
I'd suggest [reading up on how Jeff Moden][1] uses a tally table to split up data. It's exactly what you're looking for and it's extremely efficient. [1]: http://www.sqlservercentral.com/articles/Tally+Table/72993/
10 |1200

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

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.