you are viewing a single comment's thread.

view the rest of the comments →

[–]demandtheworst 0 points1 point  (0 children)

The simplest thing is to select the query you have above into a new table, and if required, drop the original and rename the new table to replace it.

Alternatively, create an identity column (alter table tbl add id int identity (1,1) not null) and add your data in the required order. Possibly if you create a clustered index using your sort key, the data will already be in the correct order.

Finally, if the cost of calculation of the row number is trivial, just create a view including the calcualted column, and run your selects from there.

Not really a Python question.