Click here to Skip to main content
15,074,394 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi
it is my query
SQL
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;


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
Posted
Updated 16-May-21 3:52am
Comments
[no name] 3-Jul-14 12:01pm
   
And the version of SQL Server on your server is? The version on your local system is?
CHill60 3-Jul-14 12:01pm
   
I guess you were using SQL Server 2012 on the server? AFAIK 2008 doesn't support offset fetch
member33 3-Jul-14 12:06pm
   
i think u cannnot use fetch in select of sql server
try select distinct top 1 *


http://en.wikipedia.org/wiki/Select_(SQL)#FETCH_FIRST_clause

1 solution

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:


SQL
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


You can also go through this FETCH NEXT

Hope this will help you.

Cheers.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900