批量添加、批量修改

--查询满足条件数据
DECLARE @Table NVARCHAR(10)
SELECT @Table=ItemValue FROM dbo.Sys_SysParameterItems WHERE SysParameterKeyId=‘6F74A9E3-8346-4BFE-81A3-C30547542FE2‘ AND itemno=‘70‘
IF @Table=‘A‘
BEGIN
--查询当日满足条件的房源信息
SELECT DISTINCT NEWID()Id ,P.KeyId AS PropertyKeyId,p.PropertyStatusCategory,p.TrustType,P.PropertyNo AS bianhao,er.ChannelValue,
estate.EstateName+‘ ‘+CONVERT(VARCHAR, p.CountF)+‘室‘+CONVERT(VARCHAR,p.CountT)+‘厅‘+CONVERT(VARCHAR,p.CountW) +‘卫 ‘+ISNULL(att.AttName,‘‘) AS title,
p.CountF,p.CountT,p.CountW,bul.FloorAll,p.Floor,p.Square,ISNULL(chaox.ItemName,‘其他‘) AS ItemName,(CASE WHEN year(convert(datetime,bul.CompleteYear))=‘1900‘ THEN ‘1901‘ ELSE year(convert(datetime,bul.CompleteYear))END ) as CompleteYear,ISNULL(zhuangxiu.ItemName,‘毛坯‘) AS zhuangxiuqingkuang,
ISNULL( yongtu.ItemName,‘其他‘) AS fangwuleixing,bul.BuildingName AS loudong,bul.BuildingName as danyuan,h.HouseNo AS menpaihao,
bul.BuildingName AS loudongdanwei,bul.BuildingName AS danyuandanwei,
(CASE WHEN p.TrustType=1 THEN sale.SalePrice*10000 WHEN p.TrustType=3 THEN sale.SalePrice*10000 ELSE NULL END) jiage,
(CASE WHEN p.TrustType=2 THEN rent.RentPrice WHEN p.TrustType=3 THEN rent.RentPrice ELSE NULL END) rentjiage,
(case when p.TrustType=1 THEN (SELECT TOP 1 LEFT(pe.PropertySaleAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1)
when p.TrustType=3 THEN (SELECT TOP 1 LEFT(pe.PropertySaleAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1) ELSE NULL END) fangyuanxiangqing,
(case when p.TrustType=2 THEN (SELECT TOP 1 LEFT(pe.PropertyAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1)
when p.TrustType=3 THEN (SELECT TOP 1 LEFT(pe.PropertyAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1) ELSE NULL END) rentfangyuanxiangqing,
(CASE WHEN p.TrustType=2 THEN 1 WHEN p.TrustType=3 THEN 1 ELSE NULL END) rentType,
(CASE WHEN p.TrustType=2 THEN fukuan.ItemName WHEN p.TrustType=3 THEN fukuan.ItemName ELSE NULL END) paymentTerms,
GETDATE() AS CreateTime,GETDATE() AS UpdateTime
INTO #temp
FROM [dbo].[VW_Adm_A_PushPropertys] p
LEFT JOIN dbo.Est_Estates estate ON estate.KeyId=p.EstateKeyId
LEFT JOIN dbo.Est_Buildings bul ON bul.KeyId=p.BuildingKeyId
LEFT JOIN dbo.Est_Houses h ON h.KeyId=p.HouseKeyId
LEFT JOIN [dbo].[Est_EstateParameterRelations] er ON p.EstateKeyId=er.EstateKeyId AND er.SysParameterItemKeyId=‘B5A6301D-EA27-4B41-B24E-857DB33C4CC6‘
LEFT JOIN dbo.Sys_SysParameterItems chaox ON p.HouseDirectionKeyId=chaox.KeyId
LEFT JOIN dbo.Sys_SysParameterItems zhuangxiu ON zhuangxiu.KeyId=p.DecorationSituationKeyId
LEFT JOIN dbo.Sys_SysParameterItems yongtu ON yongtu.KeyId=p.PropertyUsageKeyId
LEFT JOIN VW_Adm_A_property_Attribute att ON att.keyid=p.KeyId
LEFT JOIN dbo.Pro_RentTrusts rent ON rent.PropertyKeyId=p.KeyId
LEFT JOIN dbo.Pro_SaleTrusts sale ON sale.PropertyKeyId=p.KeyId
LEFT JOIN dbo.Sys_SysParameterItems fukuan ON fukuan.KeyId=rent.PropertyRentPaymentTypeKeyId
LEFT JOIN dbo.Adm_PushProperty push ON push.PropertyKeyId=p.KeyId
WHERE push.KeyId IS NULL AND p.IsDelete=0 AND p.PropertyStatusCategory = 1
AND yongtu.KeyId IN(‘690b45f8-5450-4c26-b3cc-2ffa24d5e2ef‘,‘55c74e49-07bb-c488-faeb-08d2f60a03e8‘,‘3854d76d-1a9c-41ad-8443-381e4df1d60f‘,‘24990581-27dd-4690-9359-73fe6911b033‘,‘19961612-b328-44c3-bf36-9e5bf8ebc694‘,‘d21842b6-de49-4d2f-8838-a252b4e41fab‘,‘942069b8-87ea-4e9e-bfb6-b9ba31b3a3a4‘,‘6ea6f89e-3e4d-4f64-a14e-c8fea294caab‘,‘e5a98685-f85f-cff9-faeb-08d2f60a03e8‘)
AND p.EstateKeyId NOT IN(‘a9f870b4-e5cb-4b26-aca4-8329cb406ee8‘)
--插入到推送表
SELECT COUNT(1) FROM #temp
if @@rowcount>0
BEGIN
INSERT INTO dbo.Adm_PushProperty
( KeyId ,PropertyKeyId ,PropertyStatusCategory , TrustType ,
bianhao ,xiaoquId ,title , shi , ting ,
wei ,zonglouceng ,suozailouceng ,mianji ,chaoxiang ,
jianzhuniandai ,zhuangxiuqingkuang , fangwuleixing ,loudong ,
danyuan ,menpaihao , loudongdanwei , danyuandanwei , jiage ,
rentjiage , fangyuanxiangqing , rentfangyuanxiangqing , rentType ,
paymentTerms ,
CreateTime ,
UpdateTime
)
SELECT * FROM #temp
END
--查询满足条件房源修改到推送表中
SELECT DISTINCT NEWID()Id ,P.KeyId AS PropertyKeyId,p.PropertyStatusCategory,p.TrustType,P.PropertyNo AS bianhao,er.ChannelValue,
(estate.EstateName+‘ ‘+CONVERT(VARCHAR, p.CountF)+‘室‘+CONVERT(VARCHAR,p.CountT)+‘厅‘+CONVERT(VARCHAR,p.CountW) +‘卫 ‘)+ISNULL(att.AttName,‘‘) AS title,
p.CountF,p.CountT,p.CountW,bul.FloorAll,p.Floor,p.Square,ISNULL(chaox.ItemName,‘其他‘) AS chaox,(CASE WHEN year(convert(datetime,bul.CompleteYear))=‘1900‘ THEN ‘1901‘ ELSE year(convert(datetime,bul.CompleteYear))END ) as CompleteYear,ISNULL(zhuangxiu.ItemName,‘毛坯‘) AS zhuangxiuqingkuang,
ISNULL( yongtu.ItemName,‘其他‘) AS fangwuleixing,bul.BuildingName AS loudong,bul.BuildingName as danyuan,h.HouseNo AS menpaihao,
bul.BuildingName AS loudongdanwei,bul.BuildingName AS danyuandanwei,
(CASE WHEN p.TrustType=1 THEN sale.SalePrice*10000 WHEN p.TrustType=3 THEN sale.SalePrice*10000 ELSE NULL END) jiage,
(CASE WHEN p.TrustType=2 THEN rent.RentPrice WHEN p.TrustType=3 THEN rent.RentPrice ELSE NULL END) rentjiage,
(case when p.TrustType=1 THEN (SELECT TOP 1 LEFT(pe.PropertySaleAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1)
when p.TrustType=3 THEN (SELECT TOP 1 LEFT(pe.PropertySaleAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1) ELSE NULL END) fangyuanxiangqing,
(case when p.TrustType=2 THEN (SELECT TOP 1 LEFT(pe.PropertyAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1)
when p.TrustType=3 THEN (SELECT TOP 1 LEFT(pe.PropertyAssess,300) FROM Pro_PropertyExpands pe WHERE pe.PropertyKeyId=p.KeyId AND pe.Type=1) ELSE NULL END) rentfangyuanxiangqing,
(CASE WHEN p.TrustType=2 THEN 1 WHEN p.TrustType=3 THEN 1 ELSE NULL END) rentType,
(CASE WHEN p.TrustType=2 THEN fukuan.ItemName WHEN p.TrustType=3 THEN fukuan.ItemName ELSE NULL END) paymentTerms,
GETDATE() AS CreateTime,GETDATE() AS UpdateTime
INTO #updateTemp
FROM [dbo].[VW_Adm_A_PushPropertys] p
LEFT JOIN VW_Adm_PushProperty_ActionHistoryLogs viewPush ON viewPush.SourceObjectKeyId=p.KeyId
LEFT JOIN dbo.Est_Estates estate ON estate.KeyId=p.EstateKeyId
LEFT JOIN dbo.Est_Buildings bul ON bul.KeyId=p.BuildingKeyId
LEFT JOIN dbo.Est_Houses h ON h.KeyId=p.HouseKeyId
LEFT JOIN [dbo].[Est_EstateParameterRelations] er ON p.EstateKeyId=er.EstateKeyId AND er.SysParameterItemKeyId=‘B5A6301D-EA27-4B41-B24E-857DB33C4CC6‘
LEFT JOIN dbo.Sys_SysParameterItems chaox ON p.HouseDirectionKeyId=chaox.KeyId
LEFT JOIN dbo.Sys_SysParameterItems zhuangxiu ON zhuangxiu.KeyId=p.DecorationSituationKeyId
LEFT JOIN dbo.Sys_SysParameterItems yongtu ON yongtu.KeyId=p.PropertyUsageKeyId
LEFT JOIN VW_Adm_A_property_Attribute att ON att.keyid=p.KeyId
LEFT JOIN dbo.Pro_RentTrusts rent ON rent.PropertyKeyId=p.KeyId
LEFT JOIN dbo.Pro_SaleTrusts sale ON sale.PropertyKeyId=p.KeyId
LEFT JOIN dbo.Sys_SysParameterItems fukuan ON fukuan.KeyId=rent.PropertyRentPaymentTypeKeyId
RIGHT JOIN dbo.Adm_PushProperty push ON push.PropertyKeyId=p.KeyId
LEFT JOIN #temp temp ON temp.PropertyKeyId=push.PropertyKeyId
WHERE p.KeyId IS NOT NULL AND temp.PropertyKeyId IS NULL
AND (DATEDIFF(mi, push.UpdateTime,viewPush.CreateTime ) > 1 or push.xiaoquId!=er.ChannelValue)
AND yongtu.KeyId IN(‘690b45f8-5450-4c26-b3cc-2ffa24d5e2ef‘,‘55c74e49-07bb-c488-faeb-08d2f60a03e8‘,‘3854d76d-1a9c-41ad-8443-381e4df1d60f‘,‘24990581-27dd-4690-9359-73fe6911b033‘,‘19961612-b328-44c3-bf36-9e5bf8ebc694‘,‘d21842b6-de49-4d2f-8838-a252b4e41fab‘,‘942069b8-87ea-4e9e-bfb6-b9ba31b3a3a4‘,‘6ea6f89e-3e4d-4f64-a14e-c8fea294caab‘,‘e5a98685-f85f-cff9-faeb-08d2f60a03e8‘)--AND ISNULL(att.AttName,‘‘) IS NOT NULL
AND p.EstateKeyId NOT IN(‘a9f870b4-e5cb-4b26-aca4-8329cb406ee8‘)
--修改推送表数据
SELECT COUNT(1) FROM #temp
if @@rowcount>0
BEGIN
UPDATE push
SET push.PropertyStatusCategory=t.PropertyStatusCategory,
push.TrustType=t.TrustType,
push.bianhao=t.bianhao,
push.xiaoquId=t.ChannelValue,
push.title=t.title,
push.shi=t.CountF,
push.ting=t.CountT,
push.wei=t.CountW,
push.zonglouceng=t.FloorAll,
push.suozailouceng=t.Floor,
push.mianji=t.Square,
push.chaoxiang=t.chaox,
push.jianzhuniandai=t.CompleteYear,
push.zhuangxiuqingkuang=t.zhuangxiuqingkuang,
push.fangwuleixing=t.fangwuleixing,
push.loudong=t.loudong,
push.danyuan=t.danyuan,
push.menpaihao=t.menpaihao,
push.loudongdanwei=t.loudongdanwei,
push.danyuandanwei=t.danyuandanwei,
push.jiage=t.jiage,
push.rentjiage=t.rentjiage,
push.fangyuanxiangqing=t.fangyuanxiangqing,
push.rentfangyuanxiangqing=t.rentfangyuanxiangqing,
push.rentType=t.rentType,
push.paymentTerms=t.paymentTerms,
push.UpdateTime=GETDATE()
FROM dbo.Adm_PushProperty push, #updateTemp T
WHERE t.PropertyKeyId=push.PropertyKeyId
END
DROP TABLE #temp
DROP TABLE #updateTemp
END

原文地址:https://www.cnblogs.com/starts/p/11345077.html

时间: 2024-10-10 08:48:50

批量添加、批量修改的相关文章

IIS环境下如何批量添加、修改、删除绑定的域名

IIS环境下如何批量添加和修改所绑定域名 1.关闭IISADMIN服务和W3SVC服务,可以从服务里面关闭,也可以直接执行命令:net stop iisadmin /y: 2.打开“C:\WINDOWS\SYSTEM32\INETSVR”,找到Metabase.xml,这就是存放iis信息的地方了,包括IIS的配置及网站配置都在这个文件中,备份一下,防止出错: 3.找到要修改的站点,根据原来的形式添加域名绑定,保存Metabase.xml: 4.重启IIS,可直接使用IISRESET来实现: 5

myBatis批量添加,修改和删除

摘自: http://blog.csdn.net/myjlvzlp/article/details/8434376 1.批量添加元素session.insert(String string,Object o) public void batchInsertStudent(){ List<Student> ls = new ArrayList<Student>(); for(int i = 5;i < 8;i++){ Student student = new Student(

saltstack批量添加批量删除用户

批量添加用户 [[email protected] init]# cat useradds.sls{% set users = ['name1,name2'] %}{% for user in users %}{{ user }}:user.present:- shell: /bin/bash- home: /home/{{ user }}- password: '$1$sbvWg7.V$r/nWDs7g0YynB1CVsfUPA/'- groups:- {{ user }}- require:

MongoDB学习笔记~大叔分享批量添加—批量更新—批量删除

回到目录 说它是批量操作,就是说将集合对象一次提交到服务器,并对数据进行持久化,如果您的代码是一次一次的提交,那不算是批量操作!在之前的mongodb仓储中并没有对批量更新和批量删除进行实现,而今天在项目中,还是实现了这种批量的操作,并且已经通过测试,下面公开一下源代码 public void Insert(IEnumerable<TEntity> item) { var list = new List<WriteModel<TEntity>>(); foreach (

bos 第3天(easyui弹窗边界问题、取派员的添加、修改和批量删除)

BOS项目笔记 第3天 今天内容安排: 1.解决window窗口bug 2.bos项目整体需求分析(基础设置.取派.中转.路由.报表) 3.取派员添加功能 4.jQuery easyUI控件datagrid使用方式 5.基于datagrid实现取派员分页查询 6.取派员批量删除和修改 1. 修复window控件bug 将上面的js文件引入jsp页面中 2. 基础设置部分需求分析 整个基础设置部分对应需求文档2.6章节. 2.1 基础档案设置 在其他的系统中通常称为"数据字典".提供基础

ASP.NET MVC用存储过程批量添加修改数据

用Entity Framework 进行数据库交互,在代码里直接用lamda表达式和linq对数据库操作,中间为程序员省去了数据库访问的代码时间,程序员直接可以专注业务逻辑层的编写.但是对于比较复杂的表关系关联查询或者修改就比较费劲了.通常可以采用的方式是用EF执行SQL语句或者"存储过程",特别是执行复杂批量任务,当然也可以在MVC底层用ADO.NET,这里就不多说了.怎么做批量呢?这里讲讲在EF下用存储过程批量添加修改数据. 需求是这样的:需要批量添加修改产品类别的投放任务数额,每

Lync Server 2010批量添加联系人并同步联系人

最近一直帮助朋友整理Lync Server 2010,总是听他抱怨说微软的Lync不能实现组织结构等方面的联系人列表,其实也不完全没办法实现,早在OCS的年代,OCS利用Restkit tool工具进行添加联系人列表,而到了Lync的时代虽然Restkit Tool工具还在,但是已然无法利用之前的方式进行批量添加联系人了,在网上有人表示利用LyncAddContacts.vbs这个工具进行批量添加,但是所有的文章只是把国外这个作者的写的东西照抄过来并且翻译一下就成为原创发布到网络上,本人觉得现在

【AD】AD域Powershell批量添加用户组组织单元20160208

http://bbs.51cto.com/thread-1315948-1.html在上一篇文章中提到用csvde批量添加User,ou,Group,不过用csvde有几个缺点,无法添加用户密码,也无法将用户设置成不可删除对象.下面介绍下用强大的powershell如何方便的做同样的事情. 经测试,记事本必须是unicode模式,似乎无法使用.csv导入,我测试了几次,反而这样最方便.但不方便用excel编辑了,不知有人是否解决.按照惯例,先导入OU.Out.txt内资料很简单.这里的path就

【springmvc+mybatis项目实战】杰信商贸-32.出口报运修改+报运货物批量展现-批量修改控件1

上一次我们完成了出口报运业务-购销合同查询与上报,但是其中有很多东西没有完善,我们接下来逐步完成我们的出口报运剩下的业务. 我们要解决其中一个问题:我们在购销合同查询界面点击"上报"之后就会直接上报至出口报运,如果用户仅仅是误点或者测试,这个有点过于草率,我们需要加一些限制来保证操作的正确性. 还有一点就是我们的主信息不全 毛重.净重.长宽高等信息我们都没有填写,我们都应该添加.我们只能在修改中去添加它. 所以我们增加修改的方法: 回顾一下我们之前的出口报运的Mapper映射文件中已经

为Discuz! X3.2批量添加用户的python脚本

为Discuz! X3.2批量添加用户的python脚本 搭建了一个Discuz! X3.2环境用于工作,需要添加用户时没有找到合适的工具,虽然同事最终用按键精灵解决了问题,不过还是决定写一段代码留下来,也许用得上. 之所以是Python而不是PHP,只是最近在接触Python,发现在这种场合更加方便. 添加用户代码: # encoding: utf-8 ''' Created on 2015年7月1日 @author: ZhongPing ''' import urllib import ur