Skip to content

Instantly share code, notes, and snippets.

@alaawahbah
Created August 14, 2018 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alaawahbah/47532db2fa0e69563987a793f31ac012 to your computer and use it in GitHub Desktop.
Save alaawahbah/47532db2fa0e69563987a793f31ac012 to your computer and use it in GitHub Desktop.
declare @list varchar(MAX), @i int
select @i=0, @list ='4,7,12,22,19,'
while( @i < LEN(@list))
begin
declare @item varchar(MAX)
SELECT @item = SUBSTRING(@list, @i,CHARINDEX(',',@list,@i)-@i)
select @item
print @item
--do your stuff here with @item
--exec p_MyInnerProcedure @item
set @i = CHARINDEX(',',@list,@i)+1
if(@i = 0) set @i = LEN(@list)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment