信息交流、传播、提炼

nice to meet you

博客园 首页 新随笔 联系 订阅 管理
declare @str nvarchar(200),@temp nvarchar(200)
declare @index int
set @str='abcd,123,abc123'
create table #temp(id int identity,value nvarchar(200))
while len(@str)>0
begin
 select @index=charindex(',',@str)
 if(@index=0)select @index=len(@str)
 select @temp = left(@str,case @index when len(@str) then @index else @index-1 end)
 select @str = right(@str,len(@str)-@index)
 insert into #temp values(@temp)
end
select * from #temp
drop table #temp
posted on 2007-10-15 15:25  seeyou  阅读(158)  评论(0)    收藏  举报