Turn the stored process

xiaoxiao2021-03-06  116

Create Proc Turnpage

@QCOLS VARCHAR (200), - Columns need to query

@QTables VARCHAR (200), - Tables and conditions for queries

@IKey Varchar (20), - Logo field

@oKey Varchar (20), - Sort field

@PageSize Int, - Row number of rows per page

@PAGENUMBER INT - Page number to display, starting from 0

AS

Set nocount on

Begin

Declare @sqltext as varchar (1000)

Declare @sqltable as varchar (1000)

Set @sqltable = 'SELECT TOP' CAST ((@ PAGENUMBER 1) * @Pagesize As Varchar (30)) '' @Qcols 'from' @QTables 'Order By

' @ OKEY ' DESC '

Set @sqltext =

'SELECT TOP' CAST (@PageSize As Varchar (30)) '*'

'From (' @sqltable ') as Tablea'

'WHERE' @IKey 'Not in (SELECT TOP'

Cast (@PAGENUMBER * @PageSize As Varchar (30)) '' @IKey

'From (' @Sqltable ') as tableb)'

Exec (@sqltext)

--Print (@sqltext)

End

Go

转载请注明原文地址:https://www.9cbs.com/read-125704.html

New Post(0)