MSSQL Function to Split Comma Delimited String

Whenever I seem to have to develop an automated ETL process, particularly when dealing with company financials, it involved taking a payment file, which is full of numbers that are comma delimited, and inserting it into an SQL table, so we can perform some data cleansing, reporting, and loading into financial systems.Лангуст

For the sake of brevity, I’ll just keep this as simple as possible. Let’s just create a dummy table, and put some example data into it:

So now you’ll have some dummy data in a table example, that will be a single string but will have comma’s separating each value.

Create the below function:

Use this function like this:

This will give you: