create table #tempOrders --创建临时表
(
row smallint not null IDENTITY(1,1),
CustomerID nchar(5) null,
EmployeeID int null,
ShipCity nvarchar(15) null
)
--填充临时表
insert into #tempOrders(CustomerID,EmployeeID,ShipCity) select CustomerID,EmployeeID,ShipCity From Orders
--获取分页数据
select * from #tempOrders where row>=5 and row<=10
Marked

本文介绍了一种使用SQL创建临时表进行数据填充的方法,并通过该临时表实现特定范围内的分页查询。具体步骤包括:首先创建一个临时表并设置标识字段,接着从原始表中填充数据到临时表,最后通过简单的SQL查询语句获取指定范围内的记录。
23万+





