SQL Server 2014 - Offset with fetch next
up vote
1
down vote
favorite
I'm trying to run this code, but I get the error:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'OFFSET'.
Msg 153, Level 15, State 2, Line 4
Invalid use of the NEXT option in the FETCH statement.
This is my code:
SELECT *
FROM dbp.Expats_Gesamt AS P
ORDER BY P.last_name
OFFSET 10 ROWS
FETCH NEXT 20 ROWS ONLY
sql-server
add a comment |
up vote
1
down vote
favorite
I'm trying to run this code, but I get the error:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'OFFSET'.
Msg 153, Level 15, State 2, Line 4
Invalid use of the NEXT option in the FETCH statement.
This is my code:
SELECT *
FROM dbp.Expats_Gesamt AS P
ORDER BY P.last_name
OFFSET 10 ROWS
FETCH NEXT 20 ROWS ONLY
sql-server
Tag theSQL Server
version that you are using. You can check itselect @@VERSION
.
– Yogesh Sharma
Nov 19 at 14:21
I can't replicate the error on SQL Server 2012, nor on fiddle. dd<>fiddle
– Larnu
Nov 19 at 14:23
Check the compatibility level of your database.OFFSET-FETCH
should only parse correctly at level 110 or higher.
– Jeroen Mostert
Nov 19 at 14:29
usedbo.
instead ofdbp
– IdontKnowEnglish
Nov 19 at 16:01
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm trying to run this code, but I get the error:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'OFFSET'.
Msg 153, Level 15, State 2, Line 4
Invalid use of the NEXT option in the FETCH statement.
This is my code:
SELECT *
FROM dbp.Expats_Gesamt AS P
ORDER BY P.last_name
OFFSET 10 ROWS
FETCH NEXT 20 ROWS ONLY
sql-server
I'm trying to run this code, but I get the error:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'OFFSET'.
Msg 153, Level 15, State 2, Line 4
Invalid use of the NEXT option in the FETCH statement.
This is my code:
SELECT *
FROM dbp.Expats_Gesamt AS P
ORDER BY P.last_name
OFFSET 10 ROWS
FETCH NEXT 20 ROWS ONLY
sql-server
sql-server
edited Nov 19 at 14:28
marc_s
568k12810991249
568k12810991249
asked Nov 19 at 14:18
Captai-N
102210
102210
Tag theSQL Server
version that you are using. You can check itselect @@VERSION
.
– Yogesh Sharma
Nov 19 at 14:21
I can't replicate the error on SQL Server 2012, nor on fiddle. dd<>fiddle
– Larnu
Nov 19 at 14:23
Check the compatibility level of your database.OFFSET-FETCH
should only parse correctly at level 110 or higher.
– Jeroen Mostert
Nov 19 at 14:29
usedbo.
instead ofdbp
– IdontKnowEnglish
Nov 19 at 16:01
add a comment |
Tag theSQL Server
version that you are using. You can check itselect @@VERSION
.
– Yogesh Sharma
Nov 19 at 14:21
I can't replicate the error on SQL Server 2012, nor on fiddle. dd<>fiddle
– Larnu
Nov 19 at 14:23
Check the compatibility level of your database.OFFSET-FETCH
should only parse correctly at level 110 or higher.
– Jeroen Mostert
Nov 19 at 14:29
usedbo.
instead ofdbp
– IdontKnowEnglish
Nov 19 at 16:01
Tag the
SQL Server
version that you are using. You can check it select @@VERSION
.– Yogesh Sharma
Nov 19 at 14:21
Tag the
SQL Server
version that you are using. You can check it select @@VERSION
.– Yogesh Sharma
Nov 19 at 14:21
I can't replicate the error on SQL Server 2012, nor on fiddle. dd<>fiddle
– Larnu
Nov 19 at 14:23
I can't replicate the error on SQL Server 2012, nor on fiddle. dd<>fiddle
– Larnu
Nov 19 at 14:23
Check the compatibility level of your database.
OFFSET-FETCH
should only parse correctly at level 110 or higher.– Jeroen Mostert
Nov 19 at 14:29
Check the compatibility level of your database.
OFFSET-FETCH
should only parse correctly at level 110 or higher.– Jeroen Mostert
Nov 19 at 14:29
use
dbo.
instead of dbp
– IdontKnowEnglish
Nov 19 at 16:01
use
dbo.
instead of dbp
– IdontKnowEnglish
Nov 19 at 16:01
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Your error suggests FETCH . . . OFFSET
clause error that means your current version that don't support it or might be version compatibility issue (you can check & set accordingly) however i don't know which version you are using.
So, i would try with subquery
instead that would support for lower version :
select top (20) p.*
from (select top (30) P.*
from dbp.Expats_Gesamt AS P
order by P.last_name
) p
order by P.last_name desc;
Considering that the OP has put "SQL Server 2014" in the question's subject, I suspect the problem is the compatibility level, and not the version of the Software.
– Larnu
Nov 19 at 14:44
@Larnu. . . That i realized on my second last edit made.
– Yogesh Sharma
Nov 19 at 14:46
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Your error suggests FETCH . . . OFFSET
clause error that means your current version that don't support it or might be version compatibility issue (you can check & set accordingly) however i don't know which version you are using.
So, i would try with subquery
instead that would support for lower version :
select top (20) p.*
from (select top (30) P.*
from dbp.Expats_Gesamt AS P
order by P.last_name
) p
order by P.last_name desc;
Considering that the OP has put "SQL Server 2014" in the question's subject, I suspect the problem is the compatibility level, and not the version of the Software.
– Larnu
Nov 19 at 14:44
@Larnu. . . That i realized on my second last edit made.
– Yogesh Sharma
Nov 19 at 14:46
add a comment |
up vote
1
down vote
Your error suggests FETCH . . . OFFSET
clause error that means your current version that don't support it or might be version compatibility issue (you can check & set accordingly) however i don't know which version you are using.
So, i would try with subquery
instead that would support for lower version :
select top (20) p.*
from (select top (30) P.*
from dbp.Expats_Gesamt AS P
order by P.last_name
) p
order by P.last_name desc;
Considering that the OP has put "SQL Server 2014" in the question's subject, I suspect the problem is the compatibility level, and not the version of the Software.
– Larnu
Nov 19 at 14:44
@Larnu. . . That i realized on my second last edit made.
– Yogesh Sharma
Nov 19 at 14:46
add a comment |
up vote
1
down vote
up vote
1
down vote
Your error suggests FETCH . . . OFFSET
clause error that means your current version that don't support it or might be version compatibility issue (you can check & set accordingly) however i don't know which version you are using.
So, i would try with subquery
instead that would support for lower version :
select top (20) p.*
from (select top (30) P.*
from dbp.Expats_Gesamt AS P
order by P.last_name
) p
order by P.last_name desc;
Your error suggests FETCH . . . OFFSET
clause error that means your current version that don't support it or might be version compatibility issue (you can check & set accordingly) however i don't know which version you are using.
So, i would try with subquery
instead that would support for lower version :
select top (20) p.*
from (select top (30) P.*
from dbp.Expats_Gesamt AS P
order by P.last_name
) p
order by P.last_name desc;
edited Nov 19 at 14:31
answered Nov 19 at 14:25
Yogesh Sharma
27.5k51335
27.5k51335
Considering that the OP has put "SQL Server 2014" in the question's subject, I suspect the problem is the compatibility level, and not the version of the Software.
– Larnu
Nov 19 at 14:44
@Larnu. . . That i realized on my second last edit made.
– Yogesh Sharma
Nov 19 at 14:46
add a comment |
Considering that the OP has put "SQL Server 2014" in the question's subject, I suspect the problem is the compatibility level, and not the version of the Software.
– Larnu
Nov 19 at 14:44
@Larnu. . . That i realized on my second last edit made.
– Yogesh Sharma
Nov 19 at 14:46
Considering that the OP has put "SQL Server 2014" in the question's subject, I suspect the problem is the compatibility level, and not the version of the Software.
– Larnu
Nov 19 at 14:44
Considering that the OP has put "SQL Server 2014" in the question's subject, I suspect the problem is the compatibility level, and not the version of the Software.
– Larnu
Nov 19 at 14:44
@Larnu. . . That i realized on my second last edit made.
– Yogesh Sharma
Nov 19 at 14:46
@Larnu. . . That i realized on my second last edit made.
– Yogesh Sharma
Nov 19 at 14:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376571%2fsql-server-2014-offset-with-fetch-next%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Tag the
SQL Server
version that you are using. You can check itselect @@VERSION
.– Yogesh Sharma
Nov 19 at 14:21
I can't replicate the error on SQL Server 2012, nor on fiddle. dd<>fiddle
– Larnu
Nov 19 at 14:23
Check the compatibility level of your database.
OFFSET-FETCH
should only parse correctly at level 110 or higher.– Jeroen Mostert
Nov 19 at 14:29
use
dbo.
instead ofdbp
– IdontKnowEnglish
Nov 19 at 16:01