Create Proc sp_publicTurnPageWebsite (@tbname nvarchar (100) = ', - table name, such as Pinyin @Pagesize INT = 10, - The number of records per page, the default is 10 @curpage int = 1, - means current page 1 @Keyfield nvarchar (100) = 'ID', - Key Field name, default is ID, the field requirement is the index in the table or the field @KeyascDesc nvarchar (4) = 'asc', - Lifting, descending order, default is ascending ASC, descending is desc @fields nvarchar (500) = '*', - the selected column name, default is all @condition nvarchar (200) = ', --where conditions, default is empty @ORDER NVARCHAR (200) = '' - Sort Condition, Default As Empty) WINCRYPTION As IF @tbname = 'Begin Raiserror (' Please specify a table name! ', 11, 1) Return End if @Pagesize <= 0 or @Curpage <0 Begin Raiserror ('The number of current pages and the number of records per page must be greater than zero!', 11, 1) Return end if @keyascdesc = 'dec' set @keyascdesc = '
char (13) declare @ Condition2 nvarchar (200) if @Condition = '' set @ Condition2 = 'where' @KeyField @KeyAscDesc '@sLastValue' else set @ Condition2 = 'and' @KeyField @KeyAscDesc '@SlastValue' set @SQL = @SQL 'SELECT TOP' CAST (@Pagesize As nvarchar (20)) '' @fields 'from' @tbname @Condition @ Condition2 @Order End Execute sp_executesql @SQL