xinjiang/DataBase/初始化及数据迁移/SGGL(WH)20210312数据迁移脚本/5、安全费用.sql

79 lines
3.1 KiB
Transact-SQL

--·ÑÓÃ
insert into SGGLDB_WH.dbo.CostGoods_CostManage
select *
from SUBHSSEDB_WH.dbo.CostGoods_CostManage as s
where s.ProjectId in (select ProjectId from SGGLDB_WH.dbo.Base_Project)
AND s.CostManageId NOT IN (select CostManageId from SGGLDB_WH.dbo.CostGoods_CostManage)
go
insert into SGGLDB_WH.dbo.CostGoods_CostManageItem
select *
from SUBHSSEDB_WH.dbo.CostGoods_CostManageItem as s
where s.CostManageId in (select CostManageId from SGGLDB_WH.dbo.CostGoods_CostManage)
AND s.CostManageItemId NOT IN (select CostManageItemId from SGGLDB_WH.dbo.CostGoods_CostManageItem)
go
insert into SGGLDB_WH.dbo.CostGoods_CostSmallDetail
select *
from SUBHSSEDB_WH.dbo.CostGoods_CostSmallDetail as s
where s.ProjectId in (select ProjectId from SGGLDB_WH.dbo.Base_Project)
AND s.CostSmallDetailId NOT IN (select CostSmallDetailId from SGGLDB_WH.dbo.CostGoods_CostSmallDetail)
go
insert into SGGLDB_WH.dbo.CostGoods_CostSmallDetailItem
select *
from SUBHSSEDB_WH.dbo.CostGoods_CostSmallDetailItem as s
where s.CostSmallDetailId in (select CostSmallDetailId from SGGLDB_WH.dbo.CostGoods_CostSmallDetail)
AND s.CostSmallDetailItemId NOT IN (select CostSmallDetailItemId from SGGLDB_WH.dbo.CostGoods_CostSmallDetailItem)
go
insert into SGGLDB_WH.dbo.CostGoods_Expense
select *
from SUBHSSEDB_WH.dbo.CostGoods_Expense as s
where s.ProjectId in (select ProjectId from SGGLDB_WH.dbo.Base_Project)
AND s.ExpenseId NOT IN (select ExpenseId from SGGLDB_WH.dbo.CostGoods_Expense)
go
insert into SGGLDB_WH.dbo.CostGoods_ExpenseDetail
select *
from SUBHSSEDB_WH.dbo.CostGoods_ExpenseDetail as s
where s.ExpenseId in (select ExpenseId from SGGLDB_WH.dbo.CostGoods_Expense)
AND s.ExpenseDetailId NOT IN (select ExpenseDetailId from SGGLDB_WH.dbo.CostGoods_ExpenseDetail)
go
insert into SGGLDB_WH.dbo.Base_GoodsCategory
select *
from SUBHSSEDB_WH.dbo.Base_GoodsCategory as s
where s.GoodsCategoryId NOT IN (select GoodsCategoryId from SGGLDB_WH.dbo.Base_GoodsCategory)
go
insert into SGGLDB_WH.dbo.CostGoods_GoodsManage
select *
from SUBHSSEDB_WH.dbo.CostGoods_GoodsManage as s
where s.ProjectId in (select ProjectId from SGGLDB_WH.dbo.Base_Project)
AND s.GoodsManageId NOT IN (select GoodsManageId from SGGLDB_WH.dbo.CostGoods_GoodsManage)
go
insert into SGGLDB_WH.dbo.CostGoods_MeasuresPlan
select *
from SUBHSSEDB_WH.dbo.CostGoods_MeasuresPlan as s
where s.ProjectId in (select ProjectId from SGGLDB_WH.dbo.Base_Project)
AND s.MeasuresPlanId NOT IN (select MeasuresPlanId from SGGLDB_WH.dbo.CostGoods_MeasuresPlan)
go
insert into SGGLDB_WH.dbo.CostGoods_PayRegistration
select *
from SUBHSSEDB_WH.dbo.CostGoods_PayRegistration as s
where s.ProjectId in (select ProjectId from SGGLDB_WH.dbo.Base_Project)
AND s.PayRegistrationId NOT IN (select PayRegistrationId from SGGLDB_WH.dbo.CostGoods_PayRegistration)
go
insert into SGGLDB_WH.dbo.CostGoods_SubPayRegistration
select *
from SUBHSSEDB_WH.dbo.CostGoods_SubPayRegistration as s
where s.ProjectId in (select ProjectId from SGGLDB_WH.dbo.Base_Project)
AND s.SubPayRegistrationId NOT IN (select SubPayRegistrationId from SGGLDB_WH.dbo.CostGoods_SubPayRegistration)
go