Hi,
Thank you, I've found this function very useful.
There is a little typo at the line
SET @list = LTRIM(RTRIM(@list)) + ','
Instead of concatenating with default value (,), you must concatenate with passed in @delimiter argument.
SET @list = LTRIM(RTRIM(@list)) + @delimiter
Without this, if you use delimiter different than comma, it will not add last row to the resulting table.
For example:
select * from DStringToTable(N'one|two', N'|')
returns table
value
-----
one
which is missing value 'two'