February 1, 2005 at 3:20 am
Is there a simple way of going directly to the last line of a table, other than using the right hand scroll bar?
yes there is two ways
right click on any line and select 'last'
or..
ctrl + end
February 1, 2005 at 5:07 am
Depends on your table - eg does it have a key field that gets bigger and bigger with each new record? Eg if the data look something like this:
ID, ....
1, ...
2, ...
.
.
.
1000000
Then you can submit a query like this:
select top 10 ID, [field1], ...
from ...
where ...
order by ID desc
and it will display the 10 most recently created records without displaying the ones before it.
Phil
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
February 2, 2005 at 6:26 am
Unless you use ORDER BY in your query, the last row presented in any display may not be the most recently crated row in the table.
Therefore if you care about the order of data, you must use an ORDER BY.
If you want to retrieve the most recently created row, your table design must include a column with a value that increments each time a row is inserted. Do not rely on just using a datetime column for this, for a long time computers have benn fast enough to insert multiple rows within the update period of a datetime value. You need some form of identity column if you want to retrieve the most recently inserted row.
Therefore, if you have a table containing just 1 column that can contain any valid non-ascending value, there is no way in any competant RDBMS to retrieve the most recently inserted row.
Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.
When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply