declare @id bigint
declare c cursor local fast_forward for
-- SELECT QUERY
open c
fetch next from c into @id
while @@FETCH_STATUS=0
begin
-----------------------
-----------------------
fetch next from c into @id
end
close c
deallocate c