SQL Server SELECT LAST N Rows

Diego picture Diego · Nov 16, 2010 · Viewed 683.4k times · Source

This is a known question but the best solution I've found is something like:

SELECT TOP N *
FROM MyTable
ORDER BY Id DESC

I've a table with lots of rows. It is not a posibility to use that query because it takes lot of time. So how can I do to select last N rows without using ORDER BY?

EDIT

Sorry duplicated question of this one

Answer

Niru Mukund Shah picture Niru Mukund Shah · Mar 15, 2013

You can make SQL server to select last N rows using this SQL:

select * from tbl_name order by id desc limit N;