这样就可以了!declare @string varchar(1000)
set @string='aaaa,bbbb,cccc,dddd'
set @string='select '''+replace(@string,',','''as str union all select ''')+''''
exec(@string)
set @string='aaaa,bbbb,cccc,dddd'
set @string='select '''+replace(@string,',','''as str union all select ''')+''''
exec(@string)
declare @string varchar(1000)
declare @xh char(10)
declare @sh varchar(13)
set @string='B0301075,WT0209006,WT0212197,WT0301008,WT03,,,,01013,WT0301043,WT0301061'
set @string='select * into ##tmp from (select '''+replace(@string,',','''as str union all select ''')+''') a'
exec(@string)
--print @string
select * from ##tmp
declare @str as varchar(4000)
declare @iFor int
declare @strTemp as varchar(2000)
declare @jFor intselect @str = 'B0301075,WT0209006,WT0212197,WT0301008,WT03,,,,01013,WT0301043,WT0301061'
select @iFor = 1
select @jFor = 1while (1 = 1)
begin
select @jFor = charindex(',', @str, @jFor)
if @jFor = 0
begin
select @strTemp = right(@str, len(@str)-@iFor+1)
print @strTemp
break
end
select @strTemp = substring(@str,@iFor,@jFor-@iFor)
print @strTemp
select @iFor = @jFor+1
select @jFor = @jFor+1
end