views:

541

answers:

1

When I right click on the table, I get the option to Edit TOP 200 rows. I went to option and changed this to TOP 1 row. Now when i open that row, that is not the latest but the last row of my database.

How can I Edit the latest row inserted in my table?

+1  A: 

If you want to directly access the most "recent" row in a SQL database, you'll probably need to include a timestamp column on the table and then order on it. The concept of "TOP X" is just the first X rows returned by your query according to whatever ORDER BY clause you've given. There is no native concept of time inherent in SQL tables. Rather, that sort of information is stored in transaction logs for purposes of rollback and recovery.

If you're editing a table directly in something like SQL Server Management Studio, sometimes opening the whole table will have the most recently added rows at the bottom, but this is by no means guaranteed.

phoebus
Exactly - there's no implicit order in a SQL Server table - TOP 1 without a ORDER BY just gives you one single row - it could be any of those rows, really.....
marc_s