Guest User

Untitled

a guest
Aug 14th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. declare @list varchar(MAX), @i int
  2. select @i=0, @list ='4,7,12,22,19,'
  3.  
  4. while( @i < LEN(@list))
  5. begin
  6. declare @item varchar(MAX)
  7. SELECT @item = SUBSTRING(@list, @i,CHARINDEX(',',@list,@i)-@i)
  8. select @item
  9.  
  10.  
  11. print @item
  12. --do your stuff here with @item
  13. --exec p_MyInnerProcedure @item
  14.  
  15. set @i = CHARINDEX(',',@list,@i)+1
  16. if(@i = 0) set @i = LEN(@list)
  17. end
Add Comment
Please, Sign In to add comment