DECLARE @string VARCHAR(MAX)
DECLARE @delimiter CHAR(1)
set @string='RUD,UK-UTT,RJ-BNS,RJ,RJ-SWM,JH-DEO,OD-BLR,RJN,MP-AGR
set @delimiter= ','
DECLARE @start INT, @end INT
SELECT @start = 1, @end = CHARINDEX(@delimiter, @string)
WHILE(@start < LEN(@string) + 1)
BEGIN
IF @end = 0
BEGIN
SET @end = LEN(@string) + 1
select * from ‘Table’ where Column=SUBSTRING(@string, @start, @end - @start)
SET @start = @end + 1
SET @end = CHARINDEX(@delimiter, @string, @start)
END
END
No comments:
Post a Comment