[ACCEPTED]-What is the Equivalent syntax of mysql " LIMIT " clause in SQL Server-limit

Accepted answer
Score: 18

The closest thing is TOP:

Select top 5 * from tablename

You can get a range 1 ( rows 5 - 10)

SELECT * FROM (
  SELECT TOP n * FROM (
    SELECT TOP z columns      -- (z=n+skip)
    FROM tablename
    ORDER BY key ASC
  )
)
Score: 4

The closest to it is SELECT TOP X but it is only equivalent 4 to LIMIT X.

For LIMIT X, Y, there is no direct MS-SQL equivalent 3 (as far as I know). Christian's solution 2 is a good one though.

MSSQL2005 (onwards) has 1 the ROW_NUMBER syntax which might be useful:
http://msdn.microsoft.com/en-us/library/ms186734%28SQL.90%29.aspx

Score: 0

cont=until desired number is starting to 3 get results limit=Want to see how many variables

SELECT 2 TOP (limit) cve_persona FROM persona WHERE 1 (cve_persona > cont)

More Related questions