LIMIT auf MSSQL-Server?
Da es anscheinend ja keine vergleichbare Funktion zu LIMIT von MySql auf MSSQL-Servern gibt habe ich lange nach einer alternative gesucht und dann auch unter http://www.planet-source-code......p;lngWId=5 gefunden:
The following query will emulate a
SELECT emp_id,lname,fname FROM employee LIMIT 20,10
That says, give me 10 records starting at record 21. So what will be returned are rows 21-30. This is used heavily in web-based apps so you can do recordset paging.
Here is what you can do in MS SQL to emulate it (this runs on the PUBS db):
select * from (
select top 10 emp_id,lname,fname from (
select top 30 emp_id,lname,fname
from employee
order by lname asc
) as newtbl order by lname desc
) as newtbl2 order by lname asc
Popularity: 10% [?]

Leave a Reply