Splitting strings

Splitting strings

This topic comes up a lot. At least daily there's a new question that either explicitly or implicitly needs a solution requiring some kind of string splitter. As SQL Server has evolved, new functions like STRING_SPLIT (SQL Server 2016) and STRING_AGG (SQL Server 2017) have made these tasks a lot easier, which unfortunately makes older answers and blog posts less relevant and certainly less optimal. Here are some posts where I address specific solutions and overall strategy (including trying to avoid splitting strings inside SQL Server at all, even with the new function, if you can).