SQL Server
Convert a delimited string to a table using Recursive Common Table Expression
declare @string as varchar(200),@start as int, @finish as int
set @string='Sinthiya,I,,Love,You,Very,Much,'+','
with cte(start,finish) as
(
select 1 as start,CHARINDEX(',',@string) as finish
union all
select cte.finish+1 as start, CHARINDEX(',',@string,cte.finish+1) as finish
from cte where cte.finish <>0
)
select SUBSTRING(@string,cte.start,cte.finish-cte.start) from cte where cte.finish<>0
No comments:
Post a Comment