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共有,欢迎转载,但未经作者同意必须保留此段声明,且 ...
随机推荐
- 我从腾讯那“偷了”3000万QQ用户数据,出了份很有趣的独家报告!
声明: 1.目前程序已停止运行!QQ空间也已升级访问安全机制. 2.本“分析”数据源自部分用户的公开信息,并未触及隐私内容,广大网友无需担心. 3.QQ空间会不定期发布大数据分析报告,感兴趣的朋友关注 ...
- xsd、wsdl生成C#类的命令行工具使用方法
1.xsd生成C#类命令 示例:xsd <xsd文件路径> /c /o:<生成CS文件目录> <其他参数> 参数说明: /c 生成为cs文件,/d 生成DataSe ...
- MongoDB查询并更新一粟
//更新操作使用collection的Update方法,有泛型和非泛型两个版本: //其签名如下(列出了两个简单并常用的的重载,还有几个): public virtual WriteConcernRe ...
- tableviewCell的xib中collectionView签协议
- ssh scp ssh-copy-id 非22端口的操作方法
(1)首先我们来看一下ssh-copy-id的非22端口的操作方法 ssh-copy-id -i ~/.ssh/id_rsa.pub "-p 10056 wwwad@192.168.20. ...
- .net 使用PowerShell获取电脑中的UUID
UUID含义是通用唯一识别码 (Universally Unique Identifier),这 是一个软件建构的标准,也是被开源软件基金会 (Open Software Foundation, OS ...
- poj 2155 Matrix---树状数组套树状数组
二维树状数组模版,唯一困难,看题!!(其实是我英语渣) Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 22098 ...
- POJ 3258 River Hopscotch
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11031 Accepted: 4737 ...
- Tomcat Can't load AMD 64-bit .dll on a IA 32
Java.lang.UnsatisfiedLinkError: C:\apache\apache-tomcat-7.0.14\bin\tcnative-1.dll: Can't load AMD 64 ...
- Java 对象的串行化(Serialization)
1.什么是串行化 对象的寿命通常随着生成该对象的程序的终止而终止.有时候,可能需要将对象的状态保存下来,在需要时再将对象恢复.我们把对象的这种能记录自己的状态以便将来再生的能力.叫作对象的持续性(pe ...