SQL命令解析字符串。

declare @ids varchar(50)
declare @str varchar(200)
declare @i int
set @ids='11,222,333'+','

while @ids <>''
begin
 set @str = substring(@ids,1,charindex(',',@ids)-1)
 set @ids = replace(@ids,@str+',','')
 select @str,@ids
end

你可能感兴趣的:(sql)