create table DayWord
(
Id int primary key identity,
Dnum varchar(50),
Dtid int foreign key references DayType(Did),
Dtitle varchar(50),
DsubName varchar(50),
Dtime varchar(50),
SubTime datetime,
Dinfo varchar(50)
)
create table DayType
(
Did int primary key identity,
Dname varchar(50)
)
–存储过程分页
go
alter proc Page_Week03
(
@PageIndex int,
@PageSize int,
@PageCount int out
)
as
begin
declare @count int --总条数
select top(@PageSize) * from (select ROW_NUMBER() over(order by d.Id) as num,* from DayWord d join DayType dt on d.Dtid = dt.Did) as temp where num>((@PageIndex-1)*@PageSize)
select @count = count(*) from DayWord d join DayType dt on d.Dtid = dt.Did
--计算总页数
set @PageCount = ceiling(@count*1.0/@PageSize)
end
go
declare @count int
exec Page_Week03 2,2,@count out
select @count