Back to helping the original user and to discuss your critque of the vernacular. . .
declare @row int
declare @count int
declare @previd int
declare @id int
Create table #killRow
(
row int
)
select Row_Number() OVER(ORDER BY mytableID) as row, * INTO #mytemptable FROM MyTable...
select count(*) from #mytemptable
set @row = 1
set @previd = 0
while @row <= @count
begin
... do stuff here with items from #mytemptable where row = @row
select @id from #mytemptable where row = @row
if (@id == @previd)
begin
insert into #killRow (row) values(@row)
end
select @previd = id from #mytemptable where row = @row
set @row = @row + 1
end
delete from #mytemptable where row in ( select row from #killRow)
select * into mycleanedtable from #mytemptable
OR
select * into mycleanedtable from #mytemptable where row not in ( select row from #killRow )
My vernacular for looping is adequate to express the series of iterating over these rows. You can call it set based all you like, but the vernacular used to describe
the process is more than adequate.