MySQL's "LIMIT" and SQL Server

admin

Administrator
Staff member
I'm trying to write a query to MS SQL Server which will return the first n rows found (let's say ten).

With MySQL, I would use something like "SELECT * FROM table ORDER BY id LIMIT 10"

With SQL Server, I get a syntax error with the same SQL statement, so there must be a different way to LIMIT the rows returned with SQL Server.

Anyone know what it is? I'd rather not have to write a 'for' loop if I can take care of the limiting within my SQL query. Thanks!
 
Back
Top