select * from dbo.Student
----------生成批量数据------------------
declare @i int --定义一个变量
set @i=1 --给变量赋值
while( @i<=2000)
begin
declare @sex int
set @sex=@i%2
insert Student(XSName, XSSex, XSGrade, XSDZ) values('net12',
@sex,11,'aaaa')
set @i=@i+1 --改变循环变量
end
-------查询性别是1的学生,查询10条第二页---------
--------查询性别是1的学生,姓n的,查询10条第二页--------------------
select * from Student
-----分页 每次显示10- 第1次----------------
select top 10 * from Student
where XSID not in(
select top 0 XSID from Student )
-----分页 每次显示10- 第2次----------------
select top 10 * from Student
where XSID not in(
select top 10 XSID from Student )
-----分页 每次显示10- 第3次----------------
select top 10 * from Student
where XSID not in(
select top 20 XSID from Student )
--分页:排除的数是(页码-1)*条数,
---把学生的数据倒序显示,如果分页时需要
--带条件或排序时,内外查询带同样的排序和条件
select top 10 * from Student
where XSID not in(
select top 10 XSID
from Student order by XSID desc
)
order by XSID desc
-----------
select * from Student order by XSID desc
-------查询性别是1的学生,查询10条第二页---------
select * from Student where XSSex=1
转载于:https://www.cnblogs.com/xsdm/p/1060534414_qq1.html