CREATEprocedure wqnews_GetPagedWQNews (@pagesize int, @pageindex int, @docount bit) as set nocount on if(@docount=1) selectcount(ArticleID) from Article else begin declare @indextable table(id intidentity(1,1),nid int) declare @PageLowerBound int declare @PageUpperBound int set @PageLowerBound=(@pageindex-1)*@pagesize set @PageUpperBound=@PageLowerBound+@pagesize setrowcount @PageUpperBound insertinto @indextable(nid) select ArticleID from Article select O.ArticleID,O.Content,O.Title,O.PublishTime,O.UserName,O.UserLogo,O.IP,O.HomePage,O.Email,O.OICQ from Article O,@indextable t where O.ArticleID=t.nid and t.id>@PageLowerBound and t.id<=@PageUpperBound orderby t.id end set nocount off GO