Sunday, March 13, 2011

SQL Loop with Temp Table


declare @id int

while exists(select 1 from #ids)
begin
select top 1 @id = id from #ids

--
-- do stuff
--

delete from #ids where id = @id
end

No comments: