This method of parsing does not require a tally table or one of the traditional looping methods.create function ParseString(@String varchar(500), @Delimiter char(1))returns @Results table (Ordinal int, StringValue varchar(500))asbegin--function ParseString--blindman, 5/20/2008--Parses a string based upon a given single-character delimiter,--without using loops or a tally table.--test parameters--declare @String varchar(500)--declare @Delimiter char(1)--set @String = 'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R'--set @Delimiter = '/'with Results as (select 1 as Ordinal, left(@String, charindex(@Delimiter, @String + @Delimiter)-1) as StringValue, convert(varchar(500), right(@String + @Delimiter, len(@String) - charindex(@Delimiter, @String+@Delimiter) + 1)) as Remaining UNION ALL select Ordinal+1, left(Remaining, charindex(@Delimiter, Remaining)-1), right(Remaining, len(Remaining) - charindex(@Delimiter, Remaining)) from Results where len(Remaining) > 0)insert into @Results (Ordinal, StringValue)select Ordinal, StringValuefrom Resultsreturnend
e4 d5 xd5 Nf6