sqlserver中的分页语句错误,vs提示“offset附近有语法错误,在 FETCH 语句中选项 next 的用法无效。”

我的sql语句是:从三张表中进行联合查询

select t.ID as ID,t.nvcTitle as nvcTitle,t.nvcOrigin as nvcOrigin,t.nvcChargeManGH as nvcChargeManGH,t.nvcThisConnMan as nvcThisConnMan,t.intCustmorID as intCustmorID,t.nvcContent as nvcContent,t.dtmTime as dtmTime,t.nvcState as nvcState,t.nvcDemo as nvcDemo,t.nvcTelNo as nvcTelNo,c.nvcTel as nvcTel,c.nvcEmail as nvcEmail,c.QQ as QQ,c.nvcLXR as nvcLXR,c.nvcCustomerName as nvcCustomerName,e.nvcName as nvcChargeManName from sell_Tel t,baseInfo_Coustomer c,baseInfo_Employee e where t.intCustmorID=c.intCustomerID and t.nvcChargeManGH=e.nvcZGH order by ID DESC offset 0 rows fetch next 18 rows only

第1个回答  2013-09-30
sqlserver不支持offset
你这个语法错误太多了追问

那应该怎么写?能贴上您的代码吗?

追答

简单给你个例子
select top N*P ID from table where ID not in (Select top (N-1)*P ID from table order by ID)
order by ID

ID:分页标准字段,按照此字段来进行分页

N:页数
P:每页显示数目
自己改吧

追问

OK

本回答被提问者采纳
第2个回答  2013-09-29
Sql Server 什么版本
OFFSET - FETCH NEXT 是SQL Server 2012提供的新特性。追问

是2012版本的啊

追答

OFFSET - FETCH NEXT 语句没问题
offset 0 rows fetch next 18 rows only 注释掉运行下试试

追问

嗯,注释后确实没问题,但是现在需要的是分页啊,后面的fetch语句原以为可以实现分页的目的……