Reputation: 863
When I right click on a table name in SSMS 2008 and select "edit top 200", what determines the result order? Lets say I want "edit top 200" to always show the top 200 records of the table but based on descending primary key of the table. Is there a way to do this?
Upvotes: 1
Views: 56
Reputation: 46
To get this behavior, you could alter the primary key of the table to sort descending instead of ascending. The select top X and edit top X functions appear to be based on the primary key sort order.
Right click on table, click design. Then in the design window right click and select "Indexes/Keys". Go into columns of the primary key and change the sort order to be however you would like it to appear. This could have side effects (queries without an order by clause, queries that sort ASC will have to do a sort, etc).
Another option without side effects is to do your Edit Top X Rows command, then right click the results and select Pane -> SQL. You can edit the select statement to contain an order by clause of your choosing and execute it to allow you to edit the resulting rows.
Upvotes: 2