写了个创建分页存储过程的语句:(用得是数据库自带的northwoind数据库)
- SQL code
create procedure proc_GetListByPage1 @pageIndex int=1,@pageSize int=5as select top @pageIndex * from employees where employeeid not in ( select top @pageSize*(@pageIndex-1) employeeid from employees order by employeeid asc )order by employeeid asc
一运行就提示:
服务器: 消息 170,级别 15,状态 1,过程 proc_GetListByPage1,行 4
第 4 行: '(' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,过程 proc_GetListByPage1,行 6
第 6 行: '(' 附近有语法错误。
弄了一上午了,到底是哪错的捏?40分奉上
------解决方案--------------------
- SQL code
alter procedure proc_GetListByPage1 @pageIndex int=1,@pageSize int=5as select top (@pageIndex) * from employees where employeeid not in ( select top (@pageSize*(@pageIndex-1)) employeeid from employees order by employeeid asc )order by employeeid asc
------解决方案--------------------
top 要加上括号
- SQL code
create procedure proc_GetListByPage1( @pageIndex int=1, @pageSize int=5 )as select top (@pageIndex) * from employees where employeeid not in ( select top ((@pageSize)*(@pageIndex-1) ) employeeid from employees order by employeeid asc ) order by employeeid asc
------解决方案--------------------
变量前后加括号
------解决方案--------------------
日,网卡,就差了4秒