日期:2014-05-17 浏览次数:20375 次
USE [guestbook] GO /****** Object: StoredProcedure [dbo].[selectmessage] Script Date: 08/27/2012 17:40:09 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER proc [dbo].[selectmessage] @pageSize int, @pageIndex int as declare @sql nvarchar(200) if(@pageIndex<2) begin set @sql='select top '+convert(varchar(10),@pageSize)+' * from gbook' end else begin set @sql='select top '+convert(varchar(10),@pageSize)+' * from gbook where id>(select max(id) from ( select top '+convert(varchar(10),@pageSize*(@pageIndex-1))+' id from gbook order by id) a)order by id' end exec sp_executesql @sql