Thursday, July 01, 2010

Splitting Strings in T-SQL Using XML

Having this post:
And later finding this forum entry:
I have come up with my own SQL which does not require a function in order to take a series of pairs of integers and split them into a two-field result set:


Which when run on it's own, will output this:


The effect here is that a string passed in as a parameter can contain pairs (rows) of integers; each column in the rows being separated by ':' and each row being separated by ','.

This is aggregated into a single XML element, which can then be parsed into specific types in a result set (table) format.

Note: Sorry for the images, but blogger.com's online editor would not let me paste the XML source.

No comments:

Post a Comment