declare @id int <-- change your primary key type if necessary
Declare c Cursor For Select Distinct {your primary key} From {your table}
Open c
Fetch next From c into @id
While @@Fetch_Status=0 Begin
--do operations here
Fetch next From c into @id
End
Close c
Deallocate c