DECLARE @id int -- declare cursor DECLARE cur1 CURSOR FOR SELECT ID FROM dummyTable -- open cursor OPEN cur1; -- fetch next FETCH NEXT FROM cur1 INTO @id; WHILE @@FETCH_STATUS = 0 BEGIN PRINT @id; -- fetch next FETCH NEXT FROM cur1 INTO @id; END -- close cursor CLOSE cur1; -- deallocate cursor DEALLOCATE cur1; GO