the following SQL is a general-purpose paging stored procedure in server: if (Exists (SELECT * FROM sys. procedures where name= ' proc_paging '))--if proc_paging This stored procedure exists drop proc proc_paging& nbsp --then delete this stored procedure gocreate proc proc_paging ( @pageSize nvarchar (, ) @currentPage nvarchar (), @tablename nvarchar (50), & nbsp; @orderbycolumn nvarchar (), @ Wherewithand nvarchar (max)--Create stored procedure asbegin --declare variable declare @sql nvarchar (max) --stitching sqlset @sql = ' Select top ' [email protected] + ' * FROM ( select row_number ()-Over (order by ' + @orderbycol Umn+ ') as ROWID, * from ' + @tablename + ' where 1=1 ' + @wherewithand + ') as Awhere rowid> (' [email protected] + ') * ((' + @currentPage + ')-1) ' --Execute SQL command exec (@sql) endgo --test exec proc_paging, 1, ' LogiNFO ', ' id ', '
SQL Server stored procedures----Common paging