Database page stored procedure

xiaoxiao2021-03-06  105

/ * Database page stored procedure ---Equn.net Parameter Description:? TABLENAME is the search table name? Where where where where where is searching, you want to display all records to "1 = 1"? Orderby sorted for the search results, such as Order By ID DESC? CURPAGE Current Page? Page_record Per Page Number Result: • Return to Table TableName Page_Record strip record of the rule where the condition where is satisfied, the result is sorted by OrderBy * /

Create Procedure XP_page (@tablename varchar (50), @ where varchar (100), @ curpage int, @ Page_Record int)

? As

Begin

Declare @cmd varchar (500)

? Declare @upRecord Int

? set @ Uprecord = @ Curpage * @Page_Record

? set @ cmd = 'SELECT TOP' CAST (@PAGE_RECORD AS Char) '* from' @ TableName 'Where' @ Where 'and ID Not in (SELECT TOP' CAST (@upRecord As Char) ' ID from ' @ TableName ' Where ' @ WHERE ' ' @ OrderBy ') ' @ Orderby

? EXEC (@cmd)

end

Go

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

New Post(0)