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

163 lines
9.9 KiB
Transact-SQL

insert into SGGLDB.dbo.EduTrain_TrainTest select * from SUBHSSEDB.dbo.EduTrain_TrainTest
where TrainingId in (select TrainingId from SGGLDB.dbo.EduTrain_TrainRecord)
go
insert into SGGLDB.dbo.Training_TestPlan select * from SUBHSSEDB.dbo.Training_TestPlan
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Training_TestRecord select * from SUBHSSEDB.dbo.Training_TestRecord
where TestManId in (select PersonId from SGGLDB.dbo.SitePerson_Person)
go
insert into SGGLDB.dbo.EduTrain_TrainPersonRecord ( ID,ProjectId,EmpName,IdentifyId,CategoryName,RecordId,DepartId,DepartName,TrainPeriod,TotalScore,PassScore,Score,IsPass,GroupNo
,ExamNo,ExamCount,DeviceNo,OwnerDepartId,Answers,RecordName,TrainType,PaperMode,TrainMode,TrainPrincipal,TrainStartDate,TrainEndDate,TrainContent,TrainDescript)
select ID,ProjectId,EmpName,IdentifyId,CategoryName,RecordId,DepartId,DepartName,TrainPeriod,TotalScore,PassScore,Score,IsPass,GroupNo
,ExamNo,ExamCount,DeviceNo,OwnerDepartId,Answers,RecordName,TrainType,PaperMode,TrainMode,TrainPrincipal,TrainStartDate,TrainEndDate,TrainContent,TrainDescript
from SUBHSSEDB.dbo.EduTrain_TrainPersonRecord
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Training_PlanItem select * from SUBHSSEDB.dbo.Training_PlanItem
where PlanId in (select PlanId from SGGLDB.dbo.Training_Plan)
go
insert into SGGLDB.dbo.Training_Task select * from SUBHSSEDB.dbo.Training_Task
where UserId in (select PersonId from SGGLDB.dbo.SitePerson_Person)
go
insert into SGGLDB.dbo.Training_TaskItem select * from SUBHSSEDB.dbo.Training_TaskItem
where TaskId in (select TaskId from SGGLDB.dbo.Training_Task)
go
insert into SGGLDB.dbo.Training_TestPlanTraining select * from SUBHSSEDB.dbo.Training_TestPlanTraining
where TestPlanId in (select TestPlanId from SGGLDB.dbo.Training_TestPlan)
go
insert into SGGLDB.dbo.Training_TestRecordItem select * from SUBHSSEDB.dbo.Training_TestRecordItem
where TestRecordId in (select TestRecordId from SGGLDB.dbo.Training_TestRecord)
go
insert into SGGLDB.dbo.Test_TestPlan select * from SUBHSSEDB.dbo.Test_TestPlan
go
insert into SGGLDB.dbo.Test_TestPlanTraining select * from SUBHSSEDB.dbo.Test_TestPlanTraining
where TestPlanId in (select TestPlanId from SGGLDB.dbo.Test_TestPlan)
go
insert into SGGLDB.dbo.Test_TestRecord select * from SUBHSSEDB.dbo.Test_TestRecord
where TestPlanId in (select TestPlanId from SGGLDB.dbo.Test_TestPlan)
go
insert into SGGLDB.dbo.Test_TestRecordItem select * from SUBHSSEDB.dbo.Test_TestRecordItem
where TestRecordId in (select TestRecordId from SGGLDB.dbo.Test_TestRecord)
go
insert into SGGLDB.dbo.HSSE_Hazard_HazardRegisterTypes select * from SUBHSSEDB.dbo.HSSE_Hazard_HazardRegisterTypes
go
insert into SGGLDB.dbo.HSSE_Hazard_HazardRegister select * from SUBHSSEDB.dbo.HSSE_Hazard_HazardRegister
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Check_CheckSpecial(CheckSpecialId,CheckSpecialCode,ProjectId,CheckPerson,CheckTime,ScanUrl,DaySummary,
PartInUnits,PartInPersons,CheckAreas,States,CompileMan,CheckType,PartInPersonIds,PartInPersonNames)
select CheckSpecialId,CheckSpecialCode,ProjectId,CheckPerson,CheckTime,ScanUrl,DaySummary,
PartInUnits,PartInPersons,CheckAreas,States,CompileMan,CheckType,PartInPersonIds,PartInPersonNames
from SUBHSSEDB.dbo.Check_CheckSpecial
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Check_CheckSpecialDetail(CheckSpecialDetailId,CheckSpecialId,CheckItem,CheckItemType,Unqualified,CheckArea,UnitId,CompleteStatus
,LimitedDate,CompletedDate,Suggestions,HandleStep,RectifyNoticeId,CheckContent,WorkArea)
select CheckSpecialDetailId,CheckSpecialId,CheckItem,CheckItemType,Unqualified,CheckArea,UnitId,CompleteStatus
,LimitedDate,CompletedDate,Suggestions,HandleStep,RectifyNoticeId,CheckContent,WorkArea
from SUBHSSEDB.dbo.Check_CheckSpecialDetail
where CheckSpecialId in (select CheckSpecialId from SGGLDB.dbo.Check_CheckSpecial)
go
insert into SGGLDB.dbo.Check_RectifyNotices (RectifyNoticesId,ProjectId,RectifyNoticesCode,UnitId,WorkAreaId,CheckedDate
,WrongContent,SignPerson,SignDate,CompleteStatus,DutyPerson,CompleteDate,IsRectify
,CheckPerson,AttachUrl,DutyPersonId,ReCheckDate,CompleteManId,CheckManNames,HiddenHazardType
,SignPersonIsAgree,ProfessionalEngineerId,ProfessionalEngineerTime1,ProfessionalEngineerTime2
,ConstructionManagerId,ConstructionManagerTime1,ConstructionManagerTime2,ProjectManagerId
,ProjectManagerTime1,ProjectManagerTime2,DutyPersonTime,UnitHeadManId,UnitHeadManDate
,UnitHeadManIsAgree,ReCheckOpinion,States,CheckManIds)
select RectifyNoticesId,ProjectId,RectifyNoticesCode,UnitId,WorkAreaId,CheckedDate
,WrongContent,SignPerson,SignDate,CompleteStatus,DutyPerson,CompleteDate,IsRectify
,CheckPerson,AttachUrl,DutyPersonId,ReCheckDate,CompleteManId,CheckManNames,HiddenHazardType
,SignPersonIsAgree,ProfessionalEngineerId,ProfessionalEngineerTime1,ProfessionalEngineerTime2
,ConstructionManagerId,ConstructionManagerTime1,ConstructionManagerTime2,ProjectManagerId
,ProjectManagerTime1,ProjectManagerTime2,DutyPersonTime,UnitHeadManId,UnitHeadManDate
,UnitHeadManIsAgree,ReCheckOpinion,States,CheckManIds
from SUBHSSEDB.dbo.Check_RectifyNotices
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Check_RectifyNoticesFlowOperate select * from SUBHSSEDB.dbo.Check_RectifyNoticesFlowOperate
where RectifyNoticesId in (select RectifyNoticesId from SGGLDB.dbo.Check_RectifyNotices)
go
insert into SGGLDB.dbo.Check_RectifyNoticesItem select * from SUBHSSEDB.dbo.Check_RectifyNoticesItem
where RectifyNoticesId in (select RectifyNoticesId from SGGLDB.dbo.Check_RectifyNotices)
go
insert into SGGLDB.dbo.Check_PunishNotice(PunishNoticeId,ProjectId,PunishNoticeCode,UnitId,PunishNoticeDate,BasicItem,PunishMoney,
FileContents,AttachUrl,CompileMan,CompileDate,States,SignMan,ApproveMan,ContractNum,IncentiveReason,Currency)
select PunishNoticeId,ProjectId,PunishNoticeCode,UnitId,PunishNoticeDate,BasicItem,PunishMoney,
FileContents,AttachUrl,CompileMan,CompileDate,States,SignMan,ApproveMan,ContractNum,IncentiveReason,Currency
from SUBHSSEDB.dbo.Check_PunishNotice
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
--insert into SGGLDB.dbo.Check_PunishNoticeFlowOperate
--select * from SUBHSSEDB.dbo.Check_PunishNoticeFlowOperate
--where PunishNoticeId in (select PunishNoticeId from SGGLDB.dbo.Check_PunishNotice)
--go
--insert into SGGLDB.dbo.Check_PunishNoticeItem
--select * from SUBHSSEDB.dbo.Check_PunishNoticeItem
--where PunishNoticeId in (select PunishNoticeId from SGGLDB.dbo.Check_PunishNotice)
--go
insert into SGGLDB.dbo.Check_PauseNotice(PauseNoticeId,PauseNoticeCode,ProjectId,UnitId,CompileDate,ProjectPlace,WrongContent
,PauseTime,PauseContent,OneContent,SecondContent,ThirdContent,IsConfirm
,AttachUrl,States,CompileManId,SignManId,ApproveManId,UnitWorkId)
select PauseNoticeId,PauseNoticeCode,ProjectId,UnitId,CompileDate,ProjectPlace,WrongContent
,PauseTime,PauseContent,OneContent,SecondContent,ThirdContent,IsConfirm
,AttachUrl,States,CompileMan,SignMan,ApproveMan,UnitWorkId
from SUBHSSEDB.dbo.Check_PauseNotice
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
--insert into SGGLDB.dbo.Check_PauseNoticeFlowOperate
--select * from SUBHSSEDB.dbo.Check_PauseNoticeFlowOperate
--where PauseNoticeId in (select PauseNoticeId from SGGLDB.dbo.Check_PauseNotice)
--go
--insert into SGGLDB.dbo.Sys_HttpLog select * from SUBHSSEDB.dbo.Sys_HttpLog
--go
insert into SGGLDB.dbo.Sys_AccessToken select * from SUBHSSEDB.dbo.Sys_AccessToken
go
insert into SGGLDB.dbo.Check_CheckColligation select * from SUBHSSEDB.dbo.Check_CheckColligation
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Check_CheckColligationDetail select * from SUBHSSEDB.dbo.Check_CheckColligationDetail
where CheckColligationId in (select CheckColligationId from SGGLDB.dbo.Check_CheckColligation)
go
insert into SGGLDB.dbo.Meeting_AttendMeeting select * from SUBHSSEDB.dbo.Meeting_AttendMeeting
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Meeting_ClassMeeting select * from SUBHSSEDB.dbo.Meeting_ClassMeeting
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Meeting_MonthMeeting select * from SUBHSSEDB.dbo.Meeting_MonthMeeting
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Meeting_SpecialMeeting select * from SUBHSSEDB.dbo.Meeting_SpecialMeeting
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.Meeting_WeekMeeting select * from SUBHSSEDB.dbo.Meeting_WeekMeeting
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_BreakGround select * from SUBHSSEDB.dbo.License_BreakGround
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_FireWork select * from SUBHSSEDB.dbo.License_FireWork
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_HeightWork select * from SUBHSSEDB.dbo.License_HeightWork
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_LiftingWork select * from SUBHSSEDB.dbo.License_LiftingWork
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_LimitedSpace select * from SUBHSSEDB.dbo.License_LimitedSpace
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_NightWork select * from SUBHSSEDB.dbo.License_NightWork
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_OpenCircuit select * from SUBHSSEDB.dbo.License_OpenCircuit
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go
insert into SGGLDB.dbo.License_RadialWork select * from SUBHSSEDB.dbo.License_RadialWork
where ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project)
go