On several occasions I’ve been assigned the task to split a delimited string into rows.
I’ve done this in different ways, but never thought about the performance or stability of the different approaches for doing this.
So here’s my 25 cents and findings.
My first solution to this was to code a function to traverse through the string and insert a new value to a temp table for every delimiter found in the string:
|
|
Then I ran into performance issues with very long strings - pushing me to find a better solution with more performance. I began to look into the xml-aproach for solving the issue - and ended up with this:
|
|
Performance for the two different solutions is shown below:
String contains all numbers from 0 to 100 with comma as delimiter, machine 4 cores 16 gb ram and ssd.
Function: 7 ms (on average)
XML: 3 ms (on average)
No matter how long a string I send to the XML code it runs around 3 ms - the function just climbs and climbs in time (naturally).


