根据当前值设定值

时间:2018-06-26 15:10:20

标签: sql sql-server

我有一条更新声明

    Merge [dbo].[Profiles] AS P
using Staging.[AWSProfiles] AS S
 ON P.PIN = S.PIN
WHEN Matched THEN UPDATE SET 
 P.[FirstName] = S.[FirstName]
 ,P.[LastName] = S.[LastName]
 ,P.[SupervisorLastName] = S.[SupervisorLastName]
 ,P.[SupervisorFirstName] = S.[SupervisorFirstName]
 ,P.[SupervisorPin] = S.[SupervisorPin]

在表Profiles中,我有一个名为EmployeeStatusChangeDate的字段。每当GETDATE()EmployeeStatus的字段从“活动”变为“临时退出”

中的值时,我都希望将此值设置为AWSProfiles

AWSProfiles列

FirstName
LastName
SupervisorLastName
SupervisorFirstName
SupervisorPin
EmployeeStatus

个人资料列

FirstName
LastName
SupervisorLastName
SupervisorFirstName
SupervisorPin
EmployeeStatusChangeDate

如何在更新声明中做到这一点?

0 个答案:

没有答案