--建一表。 declare @t table (id int identity(1,1) primary key, pid int)--把你的表的主键导入该表。 insert into @t (pid) select id from [你的表]--这样使用@t表的id进行分页 select a.* from [你的表] a, @t b where a.id = b.pid and b.id between 起始记录 and 结束记录
--有ID自增就简单啦Declare @PageSize int --每页记录条数 Declare @CurrentPage int --当前要取的页数 Declare @maxid int --当前页前一页的最大ID --比如说每页200条,要取第20页,可以这样 set @PageSize=200 set @CurrentPage=20set rowcount @CurrentPage*(@PageSize-1) set @maxid=id from 表名 --条件自己加set rowcount @PageSize select * from 表名 where id>@maxid order by ID---其他一些东东就自己控制吧
Select Identity(int,1,1) as NewID,表.* Into #Temp From 表這樣在臨時表#Temp中就會有一列NewID,是符合你的要求的自動增一。
declare @t table (id int identity(1,1) primary key, pid int)--把你的表的主键导入该表。
insert into @t (pid) select id from [你的表]--这样使用@t表的id进行分页
select a.* from [你的表] a, @t b where a.id = b.pid and b.id between 起始记录 and 结束记录
--有ID自增就简单啦Declare @PageSize int --每页记录条数
Declare @CurrentPage int --当前要取的页数
Declare @maxid int --当前页前一页的最大ID
--比如说每页200条,要取第20页,可以这样
set @PageSize=200
set @CurrentPage=20set rowcount @CurrentPage*(@PageSize-1)
set @maxid=id from 表名 --条件自己加set rowcount @PageSize
select * from 表名 where id>@maxid order by ID---其他一些东东就自己控制吧
Into #Temp
From 表這樣在臨時表#Temp中就會有一列NewID,是符合你的要求的自動增一。