alter procedure [dbo].[cms_getrecord] @pageindex int = 1, @pagesize int = 15, @where varchar(400) = '', @orderby varchar(50) = 'record_id', @output int output as begin declare @strsql varchar(500)
declare @sql nvarchar(1000) declare @r bigint
set @sql= n'select @r=count(*) from cms_record left join cms_record_content on record_id=content_record_id and content_lang_id=1 where 1=1
'+@where exec sp_executesql @sql, n' @r bigint output', @r output set @output= @r --set @output = @@rowcount if(@pageindex =1) begin set @strsql='select top '+str(@pagesize)+' record_id,record_order_num,record_section_id,record_display,record_display_from,record_display_to,record_pdf_filename,record_picture_filename,record_word_filename,record_related_links_category,record_url,record_sample_type,record_sample_category,record_status,content_title,content_detail from cms_record left join cms_record_content on record_id=content_record_id and content_lang_id=1 where 1=1
'+@where+' order by
'+@orderby+' asc' end else begin set @strsql='select top '+str(@pagesize)+' record_id,record_order_num,record_section_id,record_display,record_display_from,record_display_to,record_pdf_filename,record_picture_filename,record_word_filename,record_related_links_category,record_url,record_sample_type,record_sample_category,record_status,content_title,content_detail from cms_record left join cms_record_content on record_id=content_record_id and content_lang_id=1 where (
'+@orderby +' < ( select min(
'+@orderby+') from ( select top '+str(@pagesize*(@pageindex-1))+' * from cms_record left join cms_record_content on record_id=content_record_id and content_lang_id=1 order by '
+@orderby+' asc) as temptable)) order by '+ @orderby+' asc' end
exec(@strsql) end
分頁儲存過程 分頁儲存過程
分頁儲存過程 alter proc dbo p pageshow pagesize int,每頁大小 currentpage int out,當前頁 housename nvarchar 50 房產名稱 totalcount int out,總記錄數 totalpage int out 總頁數 as...
分頁儲存過程
create proc p sobigo percentpage tblname varchar 255 t category 表名 strgetfields varchar 1000 需要返回的列 fldname varchar 255 排序的欄位名 pagesize int 10,頁尺寸 pag...
分頁儲存過程
create procedure pro select pageindex int,pagesize int as select student.sno,student.sname,student.s grade.math,grade.physics,grade.huaxue,grade.chine...