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 as s
where s.ProjectId in (select ProjectId from SGGLDB.dbo.Base_Project) 
AND s.RectifyNoticesId NOT IN (select RectifyNoticesId from SGGLDB.dbo.Check_RectifyNotices) 
go

insert into SGGLDB.dbo.Check_RectifyNoticesFlowOperate
select *
from SUBHSSEDB.dbo.Check_RectifyNoticesFlowOperate as s
where s.RectifyNoticesId in (select RectifyNoticesId from SGGLDB.dbo.Check_RectifyNotices) 
AND s.FlowOperateId NOT IN (select FlowOperateId from SGGLDB.dbo.Check_RectifyNoticesFlowOperate) 
go

update SGGLDB.dbo.Check_RectifyNotices set States=2
where States is  null
go