sqlserver ce 中 分页查询语句如何写?好像ce中不支持top,有没有其他替代的sql呢?

sqlserver ce 4.0支持top了,嗨。找了很久!
2024-12-16 08:46:07
推荐回答(2个)
回答1:

SELECT * FROM (
SELECT row_number() over(order by '排序字段') AS rowNumbers,t.* FROM (
你原来的Sql
) t ) t WHERE t.rowNumbers between 1 AND 10

回答2:

if (object_id('pro', 'P') is not null) ---存储过程分页
drop proc pro
go
create procedure pro
@pageIndex int, --页码
@pageSize int--页大小
as
declare @startRow int, @endRow int
set @startRow = (@pageIndex - 1) * @pageSize +1
set @endRow = @startRow + @pageSize -1 --@pageindex*@pagesize
select * from (
select *, row_number() over (order by sno asc) as number from student) t
where t.number between @startRow and @endRow;--表名列名作为参数必须拼接执行
go
exec pro 2, 2
go