FETCH语句中NEXT选项的使用无效 [英] Invalid usage of the option NEXT in the FETCH statement

查看:113
本文介绍了FETCH语句中NEXT选项的使用无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


这是我的查询

hi
it is my query

SELECT DISTINCT  * FROM [tbl_Contents] inner join [tbl_Box_Contents] on [tbl_Box_Contents].[boxID]=3 WHERE  ([tbl_Contents].[Feature] = 'false')  and ([tbl_Contents].[ID]=[tbl_Box_Contents].[newsID]) and ([tbl_Contents].[Approve]='true') ORDER BY [tbl_Contents].[datetimeContent] DESC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY;





它在我服务器上的sql server中工作

但在本地生成以下错误



消息102,等级15,状态1,行1

'OFFSET'附近的语法不正确。

消息153,级别15,状态2,行1

FETCH语句中NEXT选项的使用无效。





请帮帮我



it is worked in my sql server on the server
but in local generate below error in

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'OFFSET'.
Msg 153, Level 15, State 2, Line 1
Invalid usage of the option NEXT in the FETCH statement.


please help me

推荐答案





如上所述,您的服务器和本地可能有不同版本的SQL。



在SQL Server 2012中,SELECT语句的ORDER中有两个新参数允许您检索固定行数的BY子句:





Hi,

As suggested above, there might be different versions of SQL on your server and your local.

In SQL Server 2012, there are two new arguments in the SELECT statement's ORDER BY clause that let you retrieve a fixed number of rows:


OFFSET <EXPR1> ROWS, which you use to specify the line number from which to start retrieving results

FETCH NEXT <EXPR2> ROWS ONLY, which you use to specify how many lines to





你也可以通过这个 FETCH NEXT



希望这会对你有所帮助。



干杯。



You can also go through this FETCH NEXT

Hope this will help you.

Cheers.


这篇关于FETCH语句中NEXT选项的使用无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆