一、脚本示例
declare @Separator varchar(10), @str varchar(100) declare @l int, @i int select @Separator=',',@str='111,22,777,99,666' select @i = len(@Separator), @l = len(@str); with cte7 as ( select 0 a, 1 b union all select b, charindex(@Separator, @str, b)+@i from cte7 where b > a ) select * from cte7
二、结果