This simple table-valued function, when combined with an APPLY operator, allows you to identify nth position strings within a string that has separators.
2019-11-01 (first published: 2019-10-22)
418 reads
This simple table-valued function, when combined with an APPLY operator, allows you to identify nth position strings within a string that has separators.
CREATE FUNCTION [capinv].[tvfn_String_Split_with_Index] ( @String varchar(max) ,@Separator varchar(10) ) RETURNS TABLE AS RETURN ( SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 1)) AS [Index], value AS [Character] FROM STRING_SPLIT(@String, @Separator) ) GO