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共有,欢迎转载,但未经作者同意必须保留此段声明,且 ...
随机推荐
- 云计算之路-阿里云上:2014年6月11日17点遇到的CPU 100%状况
今天下午17:00-17:05之间,在请求量没有明显变化的情况下,SLB中的1台云服务器的CPU突然串到100%(当时SLB中一共有3台云服务器),见下图: 造成的直接后果是请求执行时间变得超长,最长 ...
- css渐变
常这样去定义一个渐变的div: 渐变1:(双色) background: -moz-linear-gradient(top, #456d6c %, #32b66a %); %,#456d6c), co ...
- excel导入数据库
日常工作中,感觉一些基础知识需要做下笔记,可能是刚毕业的缘故吧,还保持着做笔记的习惯,但根据以往经验,纸质笔记最多保持一年,过后想找已是难过登天.电子版笔记感觉很不错,尤其是发布到网络中.笔记内容是本 ...
- 【Moqui框架】Moqui连接各种类型的数据库
Moqui连接mysql数据库 各种数据库的连接文本: -- Derby<datasource group-name="transactional" database-con ...
- 每天一个linux命令(51):rcp命令
rcp代表“remote file copy”(远程文件拷贝).该命令用于在计算机之间拷贝文件.rcp命令有两种格式.第一种格式用于文件到文件的拷贝:第二种格式用于把文件或目录拷贝到另一个目录中. 1 ...
- 调研eclipse安卓平台的开发环境
首先,我想抒发一下自己的感想.真的没想到这第一次的作业会这样的一波三折,本来以为自己已经弄好了eclipse,也弄过Java,安卓的环境配置应该不在话下,所以一拖再拖,从17号,也就是昨天开始,才着手 ...
- Spring security 和 AOP 学习
1.Spring security 登录验证拦截器 资源管理拦截器 认证和授权: 认证:登录时候确实存在此用户. 登录要认证! 授权:登录后判断权限级别,然后赋予相应的操作权限. ...
- history命令显示出详细时间
文章摘自: http://blog.csdn.net/lixiaohuiok111/article/details/34428161 http://blog.csdn.net/lixiaohuiok1 ...
- codevs2495 水叮当的舞步 IDA*
我打暴力不对,于是就看看题解,,,,,,IDA*就是限制搜索深度而已,这句话给那些会A*但不知道IDA*是什么玩意的小朋友 看题解请点击这里 上方题解没看懂的看看这:把左上角的一团相同颜色的范围,那个 ...
- ~~圣诞节到啦, canvas雪花效果, 漂亮到简直没天理啊~~
看到coding的主界面有雪花, 原来,哇, 真漂亮, 一看源代码, 哦了个去, angular写的, 压力好大, 分析分析分析分析.... 然后就写成jQ插件的样子给大家用了. 在线预览的页面是: ...