>use mytable > >scan > EXEC MySP mytable.field1 >endscan > >>
DECLARE @PK int --(or any other appropriate type for PK of your table) DECLARE @YourField1 int --(or any other appropriate type for Field1 of your table) SELECT @PK = PKField, @YourField1 = Field1 FROM YourTable INNER JOIN (SELECT MIN(PKField) AS PKField FROM YourTable WHERE /* Put your where clause here if any*/ ) Tbl1 ON YourTable.PKField = Tbl1.PKField WHILE @PK IS NOT NULL BEGIN EXEC @YourField1 SELECT @PK = PKField, @YourField1 = Field1 FROM YourTable INNER JOIN (SELECT MIN(PKField) AS PKField FROM YourTable WHERE PKField > @PK AND /* Put additional where clause here if any*/ ) Tbl1 ON YourTable.PKField = Tbl1.PKField END