(一)掌握分页存储过程
例题:从Car表中查出第四页的记录,每页为三条记录。
--分析--取一页数据出来select top 3 * from car--跳过n条记录--1.找出前n条的主键值select top 6 code from car order by code---2.跳过去select top 3 * from Car where Code not in(select top 6 code from car order by code)go--解决方法create proc UP_CAR_PAGE@pageSize int,@pageNo intasdeclare @sql varchar(500)--明白500代表的意思set @sql ='select top '+cast(@pageSize as varchar(50))+' * from car where code not in(select top '+cast(@pageSize*(@pageNo-1) as varchar(50))+' code from car order by code)'exec (@sql) --注意:exec后面要跟括号goup_car_page 3,4
(二)思维导图
SQLServer思维导图
C#思维导图