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存储过程分页--临时表存储的更多相关文章

  1. SQL存储过程分页(通用的拼接SQL语句思路实现)

    多表通用的SQL存储过程分页 案例一: USE [Community] GO /****** Object: StoredProcedure [dbo].[Common_PageList] Scrip ...

  2. 通用SQL存储过程分页以及asp.net后台调用

    创建表格并添加300万数据 use Stored CREATE TABLE UserInfo( --创建表 id ,) PRIMARY KEY not null,--添加主键和标识列 UserName ...

  3. SQL 存储过程 分页 分类: SQL Server 2014-05-16 15:11 449人阅读 评论(0) 收藏

    set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- ============================================= -- Au ...

  4. SQL 存储过程 分页查询

    ALTER PROCEDURE [dbo].[gzProc_TablePage] @tablename varchar(MAX),--表名 @selcolumn varchar(MAX),--查询字段 ...

  5. sql 存储过程 分页

    ALTER PROCEDURE [dbo].[BrokerToLenderDataShow2]@Where VARCHAR(200), --查询条件 不含'where'字符,如id>10 and ...

  6. SQL 存储过程分页

    CREATE PROC p_Team_GetTemaList @pageindex INT , @pagesize INT , @keywords VARCHAR(200) , --模糊查询 名称 标 ...

  7. SQL存储过程分页

    CREATE PROC ZDY_FY(@Pages INT, @pageRow INT) --@Pages第几页 @pageRow每页显示几行 AS BEGIN DECLARE @starNum IN ...

  8. SQL Server 存储过程 分页查询

    Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用.当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句.这样就可以提高存储过程的性能. Ø ...

  9. [转]Sql Server 分页存储过程

    本文转自: 版权声明:作者:jiankunking 出处:http://blog.csdn.net/jiankunking  本文版权归作者和CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且 ...

随机推荐

  1. JS构造函数的用法和JS原型

    $(function(){ var rec = new Rectangle(5, 10); //alert(rec.width + "*" + rec.height + " ...

  2. unity3d 赛车游戏——复位点检测

    一直没有时间写博客 昨天我的CarWaypoints插件也告一段落了 今年没回家,过年就我一个人 挺无聊的,那就休息一天写几篇博客吧 我的代码可能很少,但是思路很重要 希望不懂的朋友别只copy代码 ...

  3. 第六章 prototype和constructor

    首先我们看下面一段代码(第六章 01.htm) function myfun() //定义一个函数myfun { }; console.log(typeof (myfun.prototype)); c ...

  4. node 大牛的blog

    node一些基本的核心包的使用  http://cnodejs.org/topic/548e53f157fd3ae46b2334fd node的基本的三种框架的比较  http://cnodejs.o ...

  5. Sql Server 附加没有日志文件的数据库(.mdf)文件方法

    附加数据库,附加的时候会提醒找不到log文件 针对以上现象有两个写法的语句能解决: 写法一: USE MASTER; EXEC sp_detach_db @dbname = 'TestDB'; EXE ...

  6. [C#]Main(String[] args)参数输入问题

    Main函数是程序的入口点,它是入口点,那它的参数,又是怎样来的呢?首先写个简单的测试程序看看args到底是什么? class Program { static void Main(string[] ...

  7. python 逐行读取文件的三种方法

    方法一: 复制代码代码如下: f = open("foo.txt")             # 返回一个文件对象  line = f.readline()             ...

  8. 每天一个linux命令(14):which命令

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索:        which  查看可执行文件的位置.       whereis 查看文件的位置.         ...

  9. web服务器

    1.打破信息孤岛,实现信息的集成 2.配置文件  web.xml          定义自己的服务器应该要哪些功能! 3.tomcat 是一个servlet容器,一个web服务器. 部署:将web应用 ...

  10. git 命令的学习

    我们在安装好gitlab 之后就是怎么使用它了,这里我选择http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b806 ...