存储过程中分隔循环处理,用于批量操作数据

declare @tem varchar(300)
declare @Index int
set @tem='1,12,22,13,33,'
declare @Count int
set @Count = 1
set @Index = charindex(',',@tem)
  while @Index > 0
   begin
    select substring(@tem,@Count,@Index - @Count)
    set @Count = @Index + 1
    set @Index = charindex(',',@tem,@Count)
   end

posted on 2009-06-05 10:55  真不懂  阅读(212)  评论(0编辑  收藏  举报

导航