日期:2014-05-17 浏览次数:20868 次
CREATE TABLE Data1000000
(
[Id] [bigint] IDENTITY(1, 1) NOT NULL ,
item1 [varchar](50) NULL,
item2 [varchar](50) NULL,
item3 [varchar](50) NULL
CONSTRAINT [PK_ Data1000000_Id] PRIMARY
KEY CLUSTERED ( [Id] ASC ) WITH ( IGNORE_DUP_KEY = OFF ) ON [PRIMARY]
) ON [PRIMARY]
declare @a int
set @a = 1
while @a<=1000000
begin
INSERT INTO Data1000000 (item1,item2,item3) VALUES (NEWID(),NEWID(),NEWID())
set @a = @a + 1
end
DECLARE @currentPageIndex INT
SET @currentPageIndex = 2
SELECT TOP 5
*
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY item1 DESC ) AS rownumber ,
*
FROM Data1000000
) AS temp_table
WHERE rownumber > 5 * ( @currentPageIndex - 1 )