在Adventureworks数据库中的HumanResources.JobCandidate 表上创建一个名为 dJobCandidate的 DELETE触发器
发布网友
发布时间:2022-06-02 02:01
我来回答
共1个回答
热心网友
时间:2023-10-24 10:39
USE AdventureWorks
GO
CREATE TABLE HumanResources.JobCandidateHistory
(
JobCandidateID int not null primary key,
RejectedDate datetime not null,
Rating int not null default(5),
ContactID int null
)
USE AdventureWorks
GO
CREATE TRIGGER dJobCandidate ON HumanResources.JobCandidate
AFTER DELETE AS
BEGIN
set nocount on
declare @JobCandidateID Int
declare @RejectedDate datetime
select
@JobCandidateID = deleted.[JobCandidateID],@RejectedDate = getdate()
insert into HumanResources.JobCandidateHistory(JobCandidateID,RejectedDate)
values(@JobCandidateID,@RejectedDate)
END