Sql存储过程分页--临时表存储
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go -- =============================================
-- Author: hy
-- Create date: <Create Date,,>
-- Description: 后台企业管理
-- [P_V_EffectiveInfo_getTable] '',1,'','','','','','','','','','',-1,'',1,20
-- =============================================
ALTER PROCEDURE [dbo].[P_V_EffectiveInfo_getTable]
@strKeys varchar(300), ---搜索关键字
@intSerachType int, ---关键字类型
@intParentIndustry VARCHAR(5), -- 行业大类别
@intIndustry varchar(10), -- 行业类别
@intEffectiveType varchar(2), ---企业性质
@intOverdue varchar(2), ---核实
@dtRegStart varchar(40),--起始日期
@dtRegEnd varchar(40),--dtEndDate
@intMemberLv varchar(2),--会员级别
@intCurrState varchar(2),--状态
@strCrty varchar(30),--单位所在地
@strForm varchar(20), --来源
@intFMdredge INT, -- 是否加入自由市场
@strAdd varchar(20),--追加
@Information varchar(100),--信息完善度
@strEntLog varchar(30),--企业Logo
@PageIndex int ,--当前页码
@PageSize int--每页数据条数 AS
BEGIN
--创建临时表存储数据
if object_id('tempdb.dbo.#temp999') is not null drop table #temp999 ;
declare @iEnd int
declare @iStart int
---根据当前页和每页显示的调试获取数据跨度范围
SET @iStart = (@PageIndex-1)*@PageSize+1
SET @iEnd = (@PageIndex-1)*@PageSize+@PageSize ; ----创建带行号的零时数据插入临时表里面
with #temp1 as (
---普通的查询
select ROW_NUMBER() over(order by dtRegDate desc) as PageIndex ,strClientID ,strAccount ,strEffectiveName
,tb.strName +ISNULL((SELECT strName FROM zh_Sys_crty AS tc WHERE tc.intCrtyCode=dbo.SPLIT(ta.intAdderCode,',',1) AND tc.intParentCrtyCode=dbo.SPLIT(ta.intAdderCode,',',0) ),'') AS ctryNameintAdderCode --省+城市
,(SELECT Explainss FROM zh_Sys_Position WHERE dictNO=ta.intIndustry) AS intIndustrExplainss ,strEffectiveTel ,dtRegDate,CASE WHEN intOverdue=1 THEN '已' ELSE '未' END AS intOverdue --,MemberLv
,intStat,case WHEN ISNULL(strBlImg,'')='' THEN '无' ELSE '有' END AS strBlImg1,strEffectivephone
--是否追加
,case WHEN ISNULL(strAdditional,'')='' THEN '无' ELSE '有' END AS strAdditional
--获取后台向个人发送信息条数
,(SELECT COUNT(*) FROM dbo.zh_Sys_MessageLog tf WHERE ta.strClientID=tf.strClient AND intType=10)AS noteCount
,strForm,CASE WHEN ISNULL(strEntLog,'')='' THEN '无' ELSE '有' END AS strEntLog,strSysPerfectRecord
from V_EffectiveInfo ta LEFT JOIN dbo.zh_Sys_crty tb
ON (dbo.SPLIT(ta.intAdderCode,',',0)=tb.intCrtyCode AND tb.intParentCrtyCode=-1) WHERE
--行业搜索
(@intParentIndustry='' OR intParentIndustry=@intParentIndustry)
AND (@intIndustry='' OR intIndustry=@intIndustry)
AND (@intEffectiveType='' OR intEffectiveType=@intEffectiveType )
AND ( @intOverdue='' OR intOverdue=@intOverdue)
AND ( @dtRegStart='' OR dtRegDate>@dtRegStart )
AND ( @dtRegEnd='' OR dtRegDate<@dtRegEnd )
AND (@intMemberLv='' OR MemberLv=@intMemberLv )
AND (@intCurrState='' or intStat=@intCurrState)
AND ((@strCrty='' or dbo.split(intAdderCode,',',0)+','=@strCrty) or intAdderCode=@strCrty)
and (@strForm='' or strform=@strForm)
-- 是否开启加入自由市场
AND (@intFMdredge=-1 OR intFMdredge=@intFMdredge)
--追加
and (@strAdd='' or (@strAdd='' and isnull(strAdditional,'')<>'') or (@strAdd='' and isnull(strAdditional,'')='') )
--企业信息完善度
and (@Information='' or (@Information='' and isnull(strSysPerfectRecord,'')<>'') or (@Information='' and isnull(strSysPerfectRecord,'')='') )
--企业Logo
and (@strEntLog='' or (@strEntLog='' and isnull(strEntLog,'')<>'') or (@strEntLog='' and isnull(strEntLog,'')='') )
--AND((@intSerachType=1 AND (strAccount=@strKeys OR @strKeys='' ))
AND((@intSerachType=1 AND (@strKeys='' OR strAccount like '%'+@strKeys+'%' ))
OR (@intSerachType=2 AND ( @strKeys='' OR strEffectiveName like '%'+@strKeys+'%'))
OR (@intSerachType=3 AND ( @strKeys='' OR strEffectiveTel=@strKeys))
OR (@intSerachType=4 AND ( @strKeys='' OR strForm like '%'+@strKeys+'%'))
OR (@intSerachType=5 AND ( @strKeys='' OR strClientID like '%'+@strKeys+'%'))
) --连接表,根据ID查询省市中文名
--AND dbo.SPLIT(ta.intAdderCode,',',1)=tb.intCrtyCode ) select * into #temp999 from #temp1 ----查询临时表里面的数据并且输出
select * from #temp999 where PageIndex between CAST(@iStart as varchar) and CAST(@iEnd as varchar)ORDER BY PageIndex asc ----- 查询总数据条数
select COUNT(*) as SunPage from #temp999 ----查询当前企业对应的招聘条数总数和
select COUNT(*) as SunJob from zh_u_PositionManage WHERE strClientID in(SELECT strClientID FROM #temp999) END
Sql存储过程分页--临时表存储的更多相关文章
- SQL存储过程分页(通用的拼接SQL语句思路实现)
多表通用的SQL存储过程分页 案例一: USE [Community] GO /****** Object: StoredProcedure [dbo].[Common_PageList] Scrip ...
- 通用SQL存储过程分页以及asp.net后台调用
创建表格并添加300万数据 use Stored CREATE TABLE UserInfo( --创建表 id ,) PRIMARY KEY not null,--添加主键和标识列 UserName ...
- SQL 存储过程 分页 分类: SQL Server 2014-05-16 15:11 449人阅读 评论(0) 收藏
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- ============================================= -- Au ...
- SQL 存储过程 分页查询
ALTER PROCEDURE [dbo].[gzProc_TablePage] @tablename varchar(MAX),--表名 @selcolumn varchar(MAX),--查询字段 ...
- sql 存储过程 分页
ALTER PROCEDURE [dbo].[BrokerToLenderDataShow2]@Where VARCHAR(200), --查询条件 不含'where'字符,如id>10 and ...
- SQL 存储过程分页
CREATE PROC p_Team_GetTemaList @pageindex INT , @pagesize INT , @keywords VARCHAR(200) , --模糊查询 名称 标 ...
- SQL存储过程分页
CREATE PROC ZDY_FY(@Pages INT, @pageRow INT) --@Pages第几页 @pageRow每页显示几行 AS BEGIN DECLARE @starNum IN ...
- SQL Server 存储过程 分页查询
Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. Ø ...
- [转]Sql Server 分页存储过程
本文转自: 版权声明:作者:jiankunking 出处:http://blog.csdn.net/jiankunking 本文版权归作者和CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且 ...
随机推荐
- split 方法的正确使用姿势
本文同步自我的个人博客:http://www.52cik.com/2015/11/02/split-skill.html 通过js获取 QueryString (location.search部分) ...
- js与jquery的区别
var html = $('<a target="_blank" href="' + adCompContent.clickURL + '">< ...
- [BZOJ 2656][ZJOI2012]数列(递归+高精度)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2656 分析: 很容易想到递归分治,但遇到奇数时候f[i]=f[i/2]+f[i/2+1 ...
- c# 6.0新特性(二)
写在前面 上篇文章介绍了c#6.0的using static,Auto Property Initializers,Index Initializers新的特性,这篇文章将把剩下的几个学习一下. 原文 ...
- JSON Web Token - 在Web应用间安全地传递信息(zhuan)
来自 http://blog.leapoahead.com/2015/09/06/understanding-jwt/ JSON Web Token(JWT)是一个非常轻巧的规范.这个规范允许我们使用 ...
- Intelli IDEA 14.04开发版+注册码
Idea,一款比较出色的IDE开发工具,懂她的人,自然懂得. 本版本-14.04+注册码 注册界面 注册码: Name:happy KEY: ...
- 【Moqui业务逻辑翻译系列】Shipment Receiver Receives Shipment with Packing Slip but no PO
Shipment Receiver receives shipment. It has invoice tucked into it. Receiver records vendor name, ve ...
- 每天一个linux命令(37):free 命令
free命令可以显示Linux系统中空闲的.已用的物理内存及swap内存,及被内核使用的buffer.在Linux系统监控的工具中,free命令是最经常使用的命令之一. 1.命令格式: free [参 ...
- C头文件之<stdio.h>
(stdio.h) 该头文件主要是执行输入输出操作.文件中重要的概念是“流”(streams).“流”在函数库中用FILE表示,用指针类型FILE *来操作.有三个标准流:stdin, stdout, ...
- WEB中的cookie
首先来一篇好文章,刚好看到的: 沉默中的狂怒 —— Cookie 大喷发---------------- http://www.cnblogs.com/index-html/p/mitm-cookie ...