DECLARE @t TABLE(
id INT
)
DECLARE @m NVARCHAR(30)=‘1,9,8‘
DECLARE @i INT=CHARINDEX(‘,‘,@m);
WHILE @i!=0 BEGIN
PRINT LEFT(@m,@i-1)
INSERT INTO @t VALUES(LEFT(@m,@i-1))
SET @m=STUFF(@m,1,@i,‘‘);
SET @i=CHARINDEX(‘,‘,@m);
END
PRINT @m
INSERT INTO @t VALUES(@m)
SELECT * FROM @t