SQL Server split function

You’ll find a few functions on the internet for splitting delimited data. Here is one I found and changed slightly to do the job. Don’t remember where the original came from , so if it’s yours – thanks!

This function allows you to pass in a list and a delimiter (defaulting to a ','). It will return a table of the values with an ID for each row. You don't neccessarily need the ID, but I’ve found this useful in quickly grabbing data from a block of text like an address for example. Pass in a line break as the delimeter, then for address line 1 you can grab the row with ID of 1.

Leave a Reply

Your email address will not be published.