declare
@outputTable TABLE(
dataTable VARCHAR(256)
)
DECLARE @string VARCHAR(MAX)
DECLARE @delimiter CHAR(1)
set @string='UK-RUD,UK,RJ-BNS,RJ-J,SWM,JH-DEO,OD-BLR,CG-RJN'
set @delimiter= ','
DECLARE @start INT, @end INT
SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)
WHILE @start < LEN(@string) + 1 BEGIN
IF @end = 0
SET @end = LEN(@string) + 1
INSERT INTO @outputTable (dataTable)
VALUES(SUBSTRING(@string, @start, @end - @start))
SET @start = @end + 1
SET @end = CHARINDEX(@delimiter, @string, @start)
END
select * from @outputTable
//result
No comments:
Post a Comment