﻿CREATE TABLE [dbo].[SitePerson_Person_Bak](
	[PersonId] [nvarchar](50) NOT NULL,
	[CardNo] [nvarchar](50) NULL,
	[PersonName] [nvarchar](50) NULL,
	[Sex] [char](1) NULL,
	[IdentityCard] [nvarchar](50) NULL,
	[Address] [nvarchar](500) NULL,
	[ProjectId] [nvarchar](50) NOT NULL,
	[UnitId] [nvarchar](50) NULL,
	[TeamGroupId] [nvarchar](50) NULL,
	[WorkAreaId] [nvarchar](200) NULL,
	[WorkPostId] [nvarchar](50) NULL,
	[InTime] [datetime] NULL,
	[OutTime] [datetime] NULL,
	[OutResult] [nvarchar](50) NULL,
	[Telephone] [nvarchar](50) NULL,
	[PositionId] [nvarchar](50) NULL,
	[PostTitleId] [nvarchar](50) NULL,
	[PhotoUrl] [nvarchar](2000) NULL,
	[IsUsed] [bit] NOT NULL,
	[IsCardUsed] [bit] NOT NULL,
	[PersonIndex] [int] NULL,
	[DepartId] [nvarchar](50) NULL,
	[CertificateId] [nvarchar](50) NULL,
	[CertificateCode] [nvarchar](20) NULL,
	[CertificateLimitTime] [datetime] NULL,
	[QualificationCertificateUrl] [nvarchar](200) NULL,
	[TrainingCertificateUrl] [nvarchar](200) NULL,
	[QRCodeAttachUrl] [nvarchar](200) NULL,
	[Password] [nvarchar](50) NULL,
	[FromPersonId] [nvarchar](50) NULL,
	[AuditorId] [nvarchar](50) NULL,
	[AuditorDate] [datetime] NULL,
	[ExchangeTime] [datetime] NULL,
	[ExchangeTime2] [datetime] NULL,
	[IDCardUrl] [nvarchar](2000) NULL,
	[isprint] [char](1) NULL,
	[IsForeign] [bit] NULL,
	[IsOutside] [bit] NULL,
	[WelderCode] [nvarchar](50) NULL,
	[Birthday] [datetime] NULL,
	[WelderLevel] [nvarchar](50) NULL,
	[Remark] [nvarchar](500) NULL,
	[MainCNProfessionalId] [nvarchar](50) NULL,
	[ViceCNProfessionalId] [nvarchar](500) NULL,
	[EduLevel] [nvarchar](50) NULL,
	[MaritalStatus] [nvarchar](50) NULL,
	[IdcardType] [nvarchar](50) NULL,
	[IdcardStartDate] [datetime] NULL,
	[IdcardEndDate] [datetime] NULL,
	[IdcardForever] [char](1) NULL,
	[PoliticsStatus] [nvarchar](50) NULL,
	[IdcardAddress] [nvarchar](50) NULL,
	[Nation] [nvarchar](50) NULL,
	[CountryCode] [nvarchar](50) NULL,
	[ProvinceCode] [nvarchar](50) NULL,
	[HeadImage] [image] NULL,
	[RealNameAddTime] [datetime] NULL,
	[RealNameUpdateTime] [datetime] NULL,
 CONSTRAINT [PK_SitePerson_Person_Bak_1] PRIMARY KEY CLUSTERED 
(
	[PersonId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_Base_Depart] FOREIGN KEY([DepartId])
REFERENCES [dbo].[Base_Depart] ([DepartId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_Base_Depart]
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_Base_Position] FOREIGN KEY([PositionId])
REFERENCES [dbo].[Base_Position] ([PositionId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_Base_Position]
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_Base_PostTitle] FOREIGN KEY([PostTitleId])
REFERENCES [dbo].[Base_PostTitle] ([PostTitleId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_Base_PostTitle]
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_Base_Project] FOREIGN KEY([ProjectId])
REFERENCES [dbo].[Base_Project] ([ProjectId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_Base_Project]
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_Base_Unit] FOREIGN KEY([UnitId])
REFERENCES [dbo].[Base_Unit] ([UnitId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_Base_Unit]
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_Base_WorkPost] FOREIGN KEY([WorkPostId])
REFERENCES [dbo].[Base_WorkPost] ([WorkPostId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_Base_WorkPost]
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_ProjectData_TeamGroup] FOREIGN KEY([TeamGroupId])
REFERENCES [dbo].[ProjectData_TeamGroup] ([TeamGroupId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_ProjectData_TeamGroup]
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak]  WITH CHECK ADD  CONSTRAINT [FK_SitePerson_Person_Bak_Sys_User] FOREIGN KEY([AuditorId])
REFERENCES [dbo].[Sys_User] ([UserId])
GO

ALTER TABLE [dbo].[SitePerson_Person_Bak] CHECK CONSTRAINT [FK_SitePerson_Person_Bak_Sys_User]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'人员主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'PersonId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'卡号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'CardNo'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'人员姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'PersonName'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'性别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'Sex'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'身份证号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IdentityCard'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'家庭地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'Address'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属项目ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'ProjectId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属单位Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'UnitId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所在班组' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'TeamGroupId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作业区域' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'WorkAreaId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'岗位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'WorkPostId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'入场时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'InTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'出场时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'OutTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'出场原因' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'OutResult'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'Telephone'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职务' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'PositionId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'职称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'PostTitleId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'照片路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'PhotoUrl'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'人员是否启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IsUsed'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'考勤卡是否启用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IsCardUsed'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据接收人员ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'FromPersonId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核人ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'AuditorId'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'AuditorDate'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据交换时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'ExchangeTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据交换时间2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'ExchangeTime2'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'身份证路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IDCardUrl'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否外籍人员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IsForeign'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否外聘人员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IsOutside'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'出生日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'Birthday'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'焊工等级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'WelderLevel'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'Remark'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'证件类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IdcardType'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'证件开始时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IdcardStartDate'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'证件结束时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IdcardEndDate'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'证件是否永久有效' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IdcardForever'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'政治面貌' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'PoliticsStatus'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发证机关' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'IdcardAddress'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'民族' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'Nation'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国家' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'CountryCode'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'省份' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'ProvinceCode'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'照片base64' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'HeadImage'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'与实名制系统推送时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'RealNameAddTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'与实名制系统推送时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak', @level2type=N'COLUMN',@level2name=N'RealNameUpdateTime'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'人员表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SitePerson_Person_Bak'
GO


CREATE TRIGGER [dbo].[SitePerson_Person_Bak_TRIGGER] on [dbo].[SitePerson_Person]---创建触发器
after insert,update,delete ---------功能：插入、更新、删除
AS 
begin
declare @inserted int, @deleted int
select @inserted=COUNT(*) from inserted
select @deleted=COUNT(*) from deleted
if @inserted>0 and @deleted=0-----插入记录
begin
 insert into SitePerson_Person_Bak(PersonId,CardNo,PersonName,Sex,IdentityCard,Address,ProjectId,UnitId,TeamGroupId,WorkAreaId
		,WorkPostId,InTime,OutTime,OutResult,Telephone,PositionId,PostTitleId,PhotoUrl,IsUsed,IsCardUsed
		,PersonIndex,DepartId,CertificateId,CertificateCode,CertificateLimitTime,QualificationCertificateUrl
		,TrainingCertificateUrl,QRCodeAttachUrl,Password,FromPersonId,AuditorId,AuditorDate,ExchangeTime
		,ExchangeTime2,IDCardUrl,isprint,IsForeign,IsOutside,WelderCode,Birthday,WelderLevel,Remark
		,MainCNProfessionalId,ViceCNProfessionalId,EduLevel,MaritalStatus,IdcardType,IdcardStartDate
		,IdcardEndDate,IdcardForever,PoliticsStatus,IdcardAddress,Nation,CountryCode,ProvinceCode
		,RealNameAddTime,RealNameUpdateTime) 
		select PersonId,CardNo,PersonName,Sex,IdentityCard,Address,ProjectId,UnitId,TeamGroupId,WorkAreaId
		,WorkPostId,InTime,OutTime,OutResult,Telephone,PositionId,PostTitleId,PhotoUrl,IsUsed,IsCardUsed
		,PersonIndex,DepartId,CertificateId,CertificateCode,CertificateLimitTime,QualificationCertificateUrl
		,TrainingCertificateUrl,QRCodeAttachUrl,Password,FromPersonId,AuditorId,AuditorDate,ExchangeTime
		,ExchangeTime2,IDCardUrl,isprint,IsForeign,IsOutside,WelderCode,Birthday,WelderLevel,Remark
		,MainCNProfessionalId,ViceCNProfessionalId,EduLevel,MaritalStatus,IdcardType,IdcardStartDate
		,IdcardEndDate,IdcardForever,PoliticsStatus,IdcardAddress,Nation,CountryCode,ProvinceCode
		,RealNameAddTime,RealNameUpdateTime from inserted
 end
 else if @inserted>0 and @deleted>0----更新记录
 
begin 
DELETE FROM SitePerson_Person_Bak WHERE PersonId = (SELECT PersonId FROM DELETED)
 insert into SitePerson_Person_Bak(PersonId,CardNo,PersonName,Sex,IdentityCard,Address,ProjectId,UnitId,TeamGroupId,WorkAreaId
	,WorkPostId,InTime,OutTime,OutResult,Telephone,PositionId,PostTitleId,PhotoUrl,IsUsed,IsCardUsed
	,PersonIndex,DepartId,CertificateId,CertificateCode,CertificateLimitTime,QualificationCertificateUrl
	,TrainingCertificateUrl,QRCodeAttachUrl,Password,FromPersonId,AuditorId,AuditorDate,ExchangeTime
	,ExchangeTime2,IDCardUrl,isprint,IsForeign,IsOutside,WelderCode,Birthday,WelderLevel,Remark
	,MainCNProfessionalId,ViceCNProfessionalId,EduLevel,MaritalStatus,IdcardType,IdcardStartDate
	,IdcardEndDate,IdcardForever,PoliticsStatus,IdcardAddress,Nation,CountryCode,ProvinceCode
	,RealNameAddTime,RealNameUpdateTime) 
	select PersonId,CardNo,PersonName,Sex,IdentityCard,Address,ProjectId,UnitId,TeamGroupId,WorkAreaId
	,WorkPostId,InTime,OutTime,OutResult,Telephone,PositionId,PostTitleId,PhotoUrl,IsUsed,IsCardUsed
	,PersonIndex,DepartId,CertificateId,CertificateCode,CertificateLimitTime,QualificationCertificateUrl
	,TrainingCertificateUrl,QRCodeAttachUrl,Password,FromPersonId,AuditorId,AuditorDate,ExchangeTime
	,ExchangeTime2,IDCardUrl,isprint,IsForeign,IsOutside,WelderCode,Birthday,WelderLevel,Remark
	,MainCNProfessionalId,ViceCNProfessionalId,EduLevel,MaritalStatus,IdcardType,IdcardStartDate
	,IdcardEndDate,IdcardForever,PoliticsStatus,IdcardAddress,Nation,CountryCode,ProvinceCode
	,RealNameAddTime,RealNameUpdateTime from INSERTED
end
else if @inserted=0 and @deleted>0----删除记录
begin
  delete from SitePerson_Person_Bak
	where PersonId=(select  PersonId from deleted)
 end
end

GO

/*将人员数据写入到备份表*/
insert into SitePerson_Person_Bak select * from SitePerson_Person
go