CREATE PROC p_team_gettemalist @pageindex int, @pagesize int, @keywords VARCHAR (200),--fuzzy query name tag @cityco De VARCHAR, @verifyStatus int =0,---1 All 0 did not pass the 1 audit through @orderby int, @TotalCount int Outputas BEGIN DECLARE @PageLowerBound int DECLARE @PageUpperBound int DECLARE @Where VARCHAR = ' DECLARE @Order VARCHAR = ' DECLARE @exsql NVARCHAR (+) = ' SET @PageLowerBound = @PageSize * (@PageIndex-1 ) Set @PageUpperBound = @PageSize-1 + @PageLowerBound--conditional SET @Where = ' Where 1=1 ' IF @verifyStat Us>=0--Conditional number Beginset @Where [email protected]+ ' and verifystatus = ' +cast (@verifyStatus as VARCHAR) END IF LEN (@citycode) >0 BEGIN SET @Where [email protected]+ ' and Startcitycode = ' +cast (@ci Tycode as VARCHAR (+) + "' ENDIF LEN (@citycode) >0--Conditional string Beginset @Where [email protected]+ ' and city like '% ' +cast (@citycode asVARCHAR (+) + '% ' ' ENDIF LEN (@keywords) >0--Fuzzy query beginset @Where [email protected]+ ' and (' SET @Where [email protected]+ ' teamname like '% ' +cast (@keywords as VARCHAR) + '% ' SET @Where [email protected]+ ' or Sloga n like '% ' +cast (@keywords as VARCHAR) + '% ' ' SET @Where [email protected]+ ') ' end--sort if @orderby =0beginset @O rder= n ' ORDER by isshowindex Desc, createtime desc ' endelse beginset @Order = n ' ORDER by isshowindex ASC, createtime ASC ' END-Creates a temporary table create table #data (RowNo int IDENTITY (0, 1) NOT NULL, keyidint NOT NULL) SET @exsql =n ' INSERT Into #data (KeyID) SELECT teamid from T_team_teamlist ' [email protected] [Email protected]--select @exsql EXEC sp_executesql @exsqlSET @TotalCount = (select COUNT (1) from #data) SELECT * from dbo.t_team_teamlist T1 JOIN #data e O N t1. Teamid=e.keyid WHERE e.rowno >= @PageLowerBound and E.rowno <= @PageUpperBoundORDER by E.rowno ASC END
--The second simple point of the sub-industry create PROC p_pc_getleavecommentslist @pageindex int, @pagesize int, @TotalCount int Outputas BEGIN SELECT @TotalCount =count (0) from dbo.t_comm_leavecomments ; With CTE as (SELECT RowNumber = Row_number () up (ORDER by Createts DESC), * from dbo.t_comm_leavecomments ) C10/>select * from CTE WHERE RowNumber between (@pageindex-1) * @pageSize + 1 and @pageindex * @pageSizeORDER by Ro Wnumber END
SQL Stored Procedure Paging