14

I want to run this query on my SQL Server as follows:

Microsoft SQL Server Management Studio 10.50.1600.1

But it can't recognize the OFFSET and so shows ERROR?

SELECT * FROM dbo.tbl_MatchDetail
ORDER BY MatchDetailID
OFFSET 10 ROWS
FETCH NEXT 10 ROWS ONLY;
Milson
  • 1,525
  • 3
  • 15
  • 29
  • 6
    The syntax you show was apparently introduced in SQL Server 2012, so if you're using SQL Server 2008 per your tag, that's the problem. See [this question](http://stackoverflow.com/q/2135418/157957) for alternatives. – IMSoP Nov 03 '13 at 19:14
  • ok thanx is there any equivalent Syntax for MSSQL 2008 R2? – Milson Nov 03 '13 at 19:18
  • 1
    See the answers to the question I linked to. – IMSoP Nov 03 '13 at 19:19

2 Answers2

25

OFFSET FETCH is a new feature added to Sql Server 2012 and does not exist in Sql Server 2008.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Amir Keshavarz
  • 3,050
  • 1
  • 19
  • 26
17

Please be aware you will get an error even in 2014 if you don't have an order by. The offset must follow an order by statement.

Dale Fraser
  • 4,623
  • 7
  • 39
  • 76