As BRUCEVDE said - use an UPDATE query. Almost everything can be done in a "single" set-based logic update...
But if you cannot do it in an UPDATE, another way is to loop through a table and process rows - I do this in STORED PROCEDURES all the time
btw - this should have been posted in the DATABASE DEVELOPMENT section of this forum...
Now assuming that your "table" has an integer primary key and you are going to process them in order from first through last...
This code will loop through rows in a table - one at a time. It will do this without incurring CURSOR-type memory issues...Code:Declare @PriKey Int Set @PriKey=(Select Min(ColumnA) From SomeTable) While @PriKey is not null Begin . . ... process your row here... . . Set @PriKey=(Select Min(ColumnA) From SomeTable Where ColumnA>@PriKey) End




Reply With Quote