USE [Travel]
GO
/****** Object: StoredProcedure [dbo].[NoticeGetPagedData] Script Date: 06/13/2014 20:44:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[NoticeGetPagedData]
@pageIndex int = 1,--页码
@pageSize int =10,--页容量
@sMid int,
@rowCount float output,--输出 总行数
@pageCount float output--输出 总页数
AS
BEGIN
select @rowCount = COUNT(nId) from Notice where nMid=@sMid --求总行数
set @pageCount= CEILING(@rowCount / @pageSize)--使用 天花板 函数,将 带小数的数值,加1 去小数
select * from(select row_number() over(order by nId) as rownum ,mn.*,n.ntName from(Notice as mn inner join NoticeType as n on mn.nMid=n.ntId and nMid=@sMid))
as temp where temp.rownum >(@pageIndex-1)*@pageSize and temp.rownum <=@pageIndex*@pageSize
END
(Notice as mn inner join NoticeType as n on mn.nMid=n.ntId and nMid=@sMid 应该再后面加上nMid=@sMid再其他地方加入的话是错误的