I am searching for an equivalent to MySQL/PostgreSQLs "LIMIT" for MS SQL Server. Any ideas?
TOP as in:
SELECT TOP 50 fieldname1, fieldname2 FROM table
Note that there's no equivalent in MS SQL for the two argument LIMIT clause, i.e. something like LIMIT 50, 10 to show 10 rows from the 50th row onwards. You cannot do this in MS SQL.
Actually that second one was the one I was looking for, and I found kind of a work-around ;) I knew of the TOP, but for creating a page with a limited amount of entries the LIMIT 0,10 would be best - but this "kind of" works ;)
SELECT * FROM (
SELECT TOP x * FROM (
SELECT TOP x * FROM (
SELECT TOP (x+y) columns
FROM tablename
ORDER BY key ASC
) AS foo ORDER BY key DESC
) AS bar
) AS baz ORDER BY key ASC