We recently had the need for a string split function on our SQL Server 2014 database server, but found that there is not a built in function for that version of SQL Server. So we researched it a little and found a function definiton that mostly suited our requirements. We took the liberty of making changes that meet our requirements. (We wanted a StringSplit function that works in a similar fashion to the C# string.Split function. We modified the function downloaded from internet website contained in the comments of our script definition to also return empty strings in the 'array' (really a table, but SQL Server 2014 does not support indexable array as best as we can tell).)
While testing our version of the StringSplit function we found a need for a StringFormat function that makes use of StringSplit. Anyway long story short, we implemented a StringFormat function.
Use the following links to download the function create scripts and feel free to make any modifications you see fit for your purposes.
Note: the QueryToCreateStringFormat_3Function.sql file is one of ten versions of function wrappers to allow for different numbers of parameters from your calling script. The pattern is that the underscore number value indicates how many parameters to pass into this function _3 indicates that three parameters other than the FormatSpecifierString are passed into the function. It is fairly easy to create the other nine versions of the function starting with this function.
Thanks for reading our post and we hope these functions can be of use to you!
QueryToCreateSplitStringsFunction.sql
QueryToCreateStringFormatFunction.sql
QueryToCreateStringFormat_3Function.sql