ALTER TABLE SitePerson_Checking ADD UnitId NVARCHAR(50) null
go
ALTER TABLE SitePerson_Checking ADD UnitName NVARCHAR(500) null
go
ALTER TABLE SitePerson_Checking ADD PersonName NVARCHAR(50) null
go

/****** Object:  Index [NonClusteredIndex-20220601-105641]    Script Date: 2022/6/1 11:00:51 ******/
CREATE NONCLUSTERED INDEX [NonClusteredIndex-20220601-105641] ON [dbo].[SitePerson_Checking]
(
	[ProjectId] ASC,
	[IntoOutTime] ASC,
	[UnitId] ASC,
	[PersonName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

/****** Object:  Index [NonClusteredIndex-20220601-122818]    Script Date: 2022/6/1 12:38:37 ******/
CREATE NONCLUSTERED INDEX [NonClusteredIndex-20220601-122818] ON [dbo].[SitePerson_Checking]
(
	[ProjectId] ASC,
	[IntoOutTime] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

UPDATE A SET A.UnitId= b.UnitId
,A.PersonName=B.PersonName
,A.UnitName=C.UnitName
FROM SitePerson_Checking A,SitePerson_Person B,Base_Unit C
WHERE A.PersonId=B.PersonId AND B.UnitId=C.UnitId
go
