Wednesday, September 18, 2013
Stored Procedure for Add Master and Detail
https://www.blogger.com/blogger.g?blogID=2984821582526309017#editor/target=post;postID=1068201323384154429
Saturday, September 14, 2013
Convert a delimited string to a table in SQL
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
Subscribe to:
Posts (Atom)