mssql paging 방법론
USE [3SforU_DB]
GO
/****** Object: StoredProcedure [dbo].[sp_Circle_Activity_listw] Script Date: 08/19/2012 17:40:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_TPMBoard_listw]
@Kind_Code nvarchar(40),
@BBS_Title nvarchar(400),
@BBS_Type nvarchar(40),
@BBS_Contents nvarchar(40),
@User_ID nvarchar(40),
@page_num int,
@current_num int
AS
SELECT TOP (@page_num * 1) *
FROM TPMBoard
Where BBS_Seq not in (SELECT TOP ((@current_num - 1) * @page_num) BBS_Seq
FROM TPMBoard
WHERE (@BBS_Title is null or @BBS_Title = '' or BBS_Title like '%' + @BBS_Title + '%')
and (@BBS_Type is null or @BBS_Type = '' or BBS_Type like @BBS_Type)
and (@BBS_Contents is null or @BBS_Contents = '' or BBS_Contents like '%' + @BBS_Contents + '%')
and (@User_ID is null or @User_ID = '' or User_ID like @User_ID)
and Kind_Code = @Kind_Code
order by BBS_Seq DESC)
AND (@BBS_Title is null or @BBS_Title = '' or BBS_Title like '%' + @BBS_Title + '%')
and (@BBS_Type is null or @BBS_Type = '' or BBS_Type like @BBS_Type)
and (@BBS_Contents is null or @BBS_Contents = '' or BBS_Contents like '%' + @BBS_Contents + '%')
and (@User_ID is null or @User_ID = '' or User_ID like @User_ID)
and Kind_Code = @Kind_Code
order by BBS_Seq DESC