Incorrect syntax near OFFSET command

Why this does not work and gives me the error "Incorrect syntax near offset"

SELECT o.orderdate, o.orderid, o.empid, o.custid FROM Sales.Orders o ORDER BY o.orderdate, o.orderid OFFSET 50 ROWS FETCH NEXT 25 ROWS ONLY; 

I am using SQL Server Express 2014

+5
source share
1 answer

Check the database compatibility level. OFFSET was added in SQL Server 2012, so if your database is in 2008 compatibility mode, this keyword is not available.

View or change the database compatibility level

In T-SQL, you can check it like this:

  USE AdventureWorks2012; GO SELECT compatibility_level FROM sys.databases WHERE name = 'AdventureWorks2012'; GO 

The following is a list of compatibility levels taken from How to check SQL Server database compatibility after sp_dbcmptlevel is deprecated? :

  65 - SQL Server 6.5 70 - SQL Server 7.0 80 - SQL Server 2000 90 - SQL Server 2005 100 - SQL Server 2008/R2 110 - SQL Server 2012 120 - SQL Server 2014 130 - SQL Server 2016 140 - SQL Server 2017 
+6
source

Source: https://habr.com/ru/post/1264281/


All Articles