1:实现数据库查询指定记录的四种方法 如:从十一到二十条:
//top
select top 10 * from AdminInfo as a where a.Id not in(select top 10 Id from AdminInfo )
//MAX
//首先
select top 10 Id from AdminInfo
//其次
select MAX(Id) from AdminInfo as a where a.Id in(select top 10 Id from AdminInfo)
//整合
select top 10 * from AdminInfo as b where b.Id>(select MAX(Id) from AdminInfo as a where a.Id in(select top 10 Id from AdminInfo)
);
//between and
select * from AdminInfo where Id between 11 and 20
//第四种最为常用
select * from (select *,ROW_NUMBER()over(order by Id)as number from AdminInfo) as a where a.number between 11 and 20
2:sql中创建实现循环的存储过程:
create procedure xuanhuan (@count int ) //create 关键字:procedure 方法名(“所需参数”)
as
declare @num int ; //定义变量名
set @num=@count; //给变量名赋值
while(