Query:
DECLARE @CSVValue NVARCHAR(50)='100,101,102'
DECLARE @eachValue NUMERIC(9,0)
while len(@CSVValue) > 0
BEGIN
SET @eachValue=left(@CSVValue, charindex(N',', @CSVValue+N',')-1)
PRINT CONVERT(VARCHAR(20),@eachValue)
SET @CSVValue = stuff(@CSVValue, 1, charindex(N',', @CSVValue+N','), N'')
END
Output:
100
101
102
DECLARE @CSVValue NVARCHAR(50)='100,101,102'
DECLARE @eachValue NUMERIC(9,0)
while len(@CSVValue) > 0
BEGIN
SET @eachValue=left(@CSVValue, charindex(N',', @CSVValue+N',')-1)
PRINT CONVERT(VARCHAR(20),@eachValue)
SET @CSVValue = stuff(@CSVValue, 1, charindex(N',', @CSVValue+N','), N'')
END
Output:
100
101
102