CNCEC_SUBQHSE_WUHUAN/DataBase/初始化及数据迁移/2020-07-05HSSE-数据迁移脚本.sql

90 lines
6.0 KiB
Transact-SQL

insert into SGGLDB.dbo.Solution_SolutionTemplate select * from SUBHSSEDB.dbo.Solution_SolutionTemplate
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Solution_ConstructSolution select * from SUBHSSEDB.dbo.Solution_ConstructSolution
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Solution_LargerHazard select * from SUBHSSEDB.dbo.Solution_LargerHazard
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Solution_ExpertArgument select * from SUBHSSEDB.dbo.Solution_ExpertArgument
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Technique_ProjectSolutionTemplete select * from SUBHSSEDB.dbo.Technique_ProjectSolutionTemplete
go
insert into SGGLDB.dbo.Training_Plan select * from SUBHSSEDB.dbo.Training_Plan
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.EduTrain_TrainRecord (TrainingId,TrainingCode,ProjectId,TrainTitle,TrainContent,TrainStartDate,TrainEndDate,TeachHour
,TeachMan,TeachAddress,Remark,TrainTypeId,TrainLevelId,AttachUrl,UnitIds,States,CompileMan,TrainPersonNum,FromRecordId
,WorkPostIds,PlanId)
select TrainingId,TrainingCode,ProjectId,TrainTitle,TrainContent,TrainStartDate,TrainEndDate,TeachHour
,TeachMan,TeachAddress,Remark,TrainTypeId,TrainLevelId,AttachUrl,UnitIds,States,CompileMan,TrainPersonNum,FromRecordId
,WorkPostIds,PlanId from SUBHSSEDB.dbo.EduTrain_TrainRecord
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.EduTrain_TrainRecordDetail select * from SUBHSSEDB.dbo.EduTrain_TrainRecordDetail
where TrainingId in (select TrainingId from SGGLDB.dbo.EduTrain_TrainRecord)
go
insert into SGGLDB.dbo.OccupationHealth_HazardDetection select * from SUBHSSEDB.dbo.OccupationHealth_HazardDetection
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.OccupationHealth_OccupationalDiseaseAccident select * from SUBHSSEDB.dbo.OccupationHealth_OccupationalDiseaseAccident
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.OccupationHealth_PhysicalExamination select * from SUBHSSEDB.dbo.OccupationHealth_PhysicalExamination
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Environmental_UnexpectedEnvironmental select * from SUBHSSEDB.dbo.Environmental_UnexpectedEnvironmental
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Environmental_EnvironmentalMonitoring select * from SUBHSSEDB.dbo.Environmental_EnvironmentalMonitoring
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Environmental_EnvironmentalEmergencyPlan select * from SUBHSSEDB.dbo.Environmental_EnvironmentalEmergencyPlan
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Environmental_EIAReport select * from SUBHSSEDB.dbo.Environmental_EIAReport
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.SitePerson_DayReport(DayReportId,ProjectId,CompileMan,CompileDate,TotalPersonWorkTime,States)
select DayReportId,ProjectId,CompileMan,CompileDate,TotalPersonWorkTime,States from SUBHSSEDB.dbo.SitePerson_DayReport
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.SitePerson_DayReportDetail(DayReportDetailId,DayReportId,UnitId,WorkTime,CheckPersonNum,RealPersonNum
,PersonWorkTime,TotalPersonWorkTime,Remark,StaffData,DayNum,YearPersonWorkTime)
select DayReportDetailId,DayReportId,UnitId,WorkTime,CheckPersonNum,RealPersonNum
,PersonWorkTime,TotalPersonWorkTime,Remark,StaffData,DayNum,YearPersonWorkTime
from SUBHSSEDB.dbo.SitePerson_DayReportDetail
where DayReportId in (select DayReportId from SGGLDB.dbo.SitePerson_DayReport)
go
insert into SGGLDB.dbo.SitePerson_DayReportUnitDetail(DayReportUnitDetailId,DayReportDetailId,PostId,CheckPersonNum,RealPersonNum,PersonWorkTime,Remark)
select DayReportUnitDetailId,DayReportDetailId,PostId,CheckPersonNum,RealPersonNum,PersonWorkTime,Remark
from SUBHSSEDB.dbo.SitePerson_DayReportUnitDetail
where DayReportDetailId in (select DayReportDetailId from SGGLDB.dbo.SitePerson_DayReportDetail)
go
insert into SGGLDB.dbo.SitePerson_MonthReport(MonthReportId,ProjectId,CompileMan,CompileDate,TotalPersonWorkTime,States)
select MonthReportId,ProjectId,CompileMan,CompileDate,TotalPersonWorkTime,States from SUBHSSEDB.dbo.SitePerson_MonthReport
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.SitePerson_MonthReportDetail(MonthReportDetailId,MonthReportId,UnitId,WorkTime,CheckPersonNum,RealPersonNum,PersonWorkTime
,TotalPersonWorkTime,Remark,StaffData,DayNum,YearPersonWorkTime)
select MonthReportDetailId,MonthReportId,UnitId,WorkTime,CheckPersonNum,RealPersonNum,PersonWorkTime
,TotalPersonWorkTime,Remark,StaffData,DayNum,YearPersonWorkTime
from SUBHSSEDB.dbo.SitePerson_MonthReportDetail
where MonthReportId in (select MonthReportId from SGGLDB.dbo.SitePerson_MonthReport)
go
insert into SGGLDB.dbo.SitePerson_MonthReportUnitDetail(MonthReportUnitDetailId,MonthReportDetailId,PostId,CheckPersonNum,RealPersonNum,PersonWorkTime,Remark)
select MonthReportUnitDetailId,MonthReportDetailId,PostId,CheckPersonNum,RealPersonNum,PersonWorkTime,Remark
from SUBHSSEDB.dbo.SitePerson_MonthReportUnitDetail
where MonthReportDetailId in (select MonthReportDetailId from SGGLDB.dbo.SitePerson_MonthReportDetail)
go
insert into SGGLDB.dbo.SitePerson_Checking select * from SUBHSSEDB.dbo.SitePerson_Checking
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.SitePerson_PersonInOut select * from SUBHSSEDB.dbo.SitePerson_PersonInOut
where PersonId in (select PersonId from SGGLDB.dbo.SitePerson_Person)
go
insert into SGGLDB.dbo.SitePerson_PersonInOutNumber select * from SUBHSSEDB.dbo.SitePerson_PersonInOutNumber
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go