I want to learn how to process table rows when updating column(s), in a certain order (and not in the random or in the order that the records were created).
To illustrate my question, in the made-up example below I want to set the Ranking according to the date_time such that the older records are processed first (and get lower ranking).
create table #testTable (customer_id char(20), ranking int, date_time
Datetime, pk_value int identity )
go
insert into #testTable (customer_id, date_time) values
('MICROSOFT', '20110202')
insert into #testTable (customer_id, date_time) values
('MICROSOFT', '20120202')
insert into #testTable (customer_id, date_time) values
('MICROSOFT', '20090512')
go
declare @Rank int
set @Rank = 0
update #testTable set @Rank = @Rank + 1, ranking = @Rank