You can use temp table in the same manner as you use SQL Server cursor
create table #temp (
value1 int,
value2 int
)
Declare
@SomeValue1 int,
@SomeValue2 int
insert into #temp (
value1,
value2)
select
field1,
field2
from realTable
--where some condition
select top 1
@SomeValue1 = value1,
@SomeValue2 = value2
from #temp
-- while we have rows in the table, do work with them.
while @SomeValue1 is not null
Begin
-- Do something with value1 and value2
-- delete the row we have just worked with
delete from #temp where value1=@SomeValue1 and value2=@SomeValue2
-- don't forget this bit!! otherwise you'd be stuck in the infinite loop,
-- as variable is not reset to null on empty table
set @SomeValue1 = null
-- get the next row in the table
select top 1 @SomeValue1=value1, @SomeValue2 = value2
from #temp
End
-- here we are done, can drop the temp table
drop table #temp
Probably you would benefit from adding @ID uniqueidentifier to temp table, in case you have repeating data, and delete rows from temp table based by the ID value