IF EXISTS (SELECT * from SYSOBJECTS WHERE NAME = ' stuwebname ') DROP table stuwebnamegocreate table Stuwebname (stuid INT IDEN Tity (+) PRIMARY key,stuname varchar (2) not null,stupassword varchar (+) not null,stusex CHAR ("male"), Stuno INT Not NULL) godeclare @ID intset @ID =1while (@ID <100) BEGIN INSERT into Stuwebname (Stuname,stupassword,stusex,stuno) VAL UES (' Zhang San ' +convert (VARCHAR), @ID), ' 123 ', ' Male ', 0902 ' SET @[email protected]+1endgoselect * from Stuwebnamego-------------------------------------------------------Several of the most common sort sorts (first page of five data per page)---------------------- ---------------------------------First Use the Row_number function to sequence the columns in each column and then sort the select * FROM (select Row_number () over (ORDER by Stuid) as b,* From Stuwebname) as Awhere b> (2-1) and b<=2*5 go--first query the first 10 lines, then reverse the first 5 lines, and finally in reverse (the data back) SELECT * FROM (select TOP 5 * FR OM (SELECT TOP Ten * from Stuwebname ORDER by Stuid ASC) as-t order by Stuid DESC) as-t order by Stuid ascgo--first 6 rows, let back take Stuid The maximum value of the Select TOP 5 *from stuwebnamewhere (Stuid >= (SelecT MAX (Stuid) from (SELECT TOP ((5*1) +1) Stuid from Stuwebname Order by Stuid) as T) ORDER by Stuidgo
SQL Server Three paging methods