I’ve been waiting a long time for this. If you’ve had to split strings in SQL in the past, keep reading!
Microsoft SQL Server 2016 now has a native solution available, meaning, you can supply a delimited string and join against it like a collection of rows.
There have been many work-arounds for this over the years, but if you have SQL 2016, you don’t need them any longer.
Here’s the syntax:
SELECT * FROM STRING_SPLIT(‘a,b,cd’, ‘,’);
value -------- a b cd */
Note: this ONLY works in SQL 2016 on databases that are in 130 compatibility.