可以动态分页的存储过程
一位朋友介绍的方法:
Cretate PROCEDURE OGuess_CommonPaging @tablename varchar(50), @tablefield varchar(20), @where varchar(100), @orderby 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 '+@tablefield+' not in (SELECT TOP '+cast(@uprecord as char)+' '+@tablefield+' FROM '+@tablename+' WHERE '+@where+' '+@orderby +') '+@orderby EXEC(@cmd)
END