hello,
from an input that looks like '1,6,8,10'
i must insert as many rows as there are elements in the list.
the result should be:
A 1
A 6
A 8
A 10
how can i get rid of the comma ?
thanks for any hint.
(this is the first time that i am using sql server.)
declare @var varchar(100) , @loc smallint , @val int
set @var = '1,6,8,10'
set @var = @var + ','
set @loc = charindex(',',@var)
while @loc > 0
begin
set @val = convert(int,left(@var,@loc - 1))
Insert into UrTable values('A',@val)
set @var = substring(@var,@loc + 1,100)
set @loc = charindex(',',@var)
end
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.