为什么 SQL 将我的 'after' 触发器视为

Why is SQL treating my 'after' trigger as an instead of

我有以下触发器:

Alter trigger [dbo].[EmployeeLearningNeedsDeleteAuditTrigger]
on [dbo].[EmployeeLearningNeeds]
after delete
...

出于某种原因,SQL Management Studio 将此标记为错误,指出:

Cannot create INSTEAD OF DELETE trigger [dbo].[EmployeeLearningNeedsDeleteAuditTrigger] on [dbo].[EmployeeLearningNeeds]. This is because table has a FOREIGN KEY with cascading delete.

我不明白的是,这不是 'instead of delete' 这是 'after delete' 那么为什么会抛出这样的错误?

为了以防万一,我已经包含了触发器的内容:

as

DECLARE @Count int;
select @Count = @@ROWCOUNT;

set nocount on;

if @Count > 0
begin
            declare @RowId int;
            declare @Value varchar(max);

            select @RowId=RecordId from deleted;

            select @Value=CONVERT(varchar, (select RecordId from deleted));
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'RecordId', @Value, '';

            select @Value=RTRIM(surname)+', '+RTRIM(forename1)+' '+RTRIM(forename2) from employee where emp_no=(select EmployeeId from deleted);
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'EmployeeName', @Value, '';

            select @Value=CONVERT(varchar, (select TrainingEventId from deleted));
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'TrainingEventId', @Value, '';

            select @Value=[Description] from TrainingEventPart where RecordId=(select TrainingEventPartId from deleted);
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'TrainingEventPart', @Value, '';

            select @Value=NeedDescription from deleted;
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'NeedDescription', @Value, '';

            select @Value=CONVERT(varchar, (select TargetDate from deleted), 103);
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'TargetDate', @Value, '';

            select @Value=CONVERT(varchar, (select DateAchieved from deleted), 103);
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'DateAchieved', @Value, '';

            select @Value=[Description] from LearningNeedPriority where Code=(select [Priority] from deleted);
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'Priority', @Value, '';

            select @Value=CONVERT(varchar, (select RenewableAfter from deleted));
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'RenewableAfter', @Value, '';

            if (select Renewed from deleted)=1
                            select @Value='Yes';
            else
                            select @Value='No';
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'Renewed', @Value, '';

            if (select SelfNominated from deleted)=1
                            select @Value='Yes';
            else
                            select @Value='No';
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'SelfNominated', @Value, '';

            select @Value=CONVERT(varchar, (select DateNominated from deleted), 103);
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'DateNominated', @Value, '';

            if (select Approved from deleted)=1
                            select @Value='Yes';
            else
                            select @Value='No';
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'Approved', @Value, '';

            select @Value=ApprovedBy from deleted;
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'ApprovedBy', @Value, '';

            select @Value=ActionBy from deleted;
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'ActionBy', @Value, '';

            select @Value=CONVERT(varchar, (select EstimatedCost from deleted));
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'EstimatedCost', @Value, '';

            select @Value=Comment1 from deleted;
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'Comment1', @Value, '';

            select @Value=Comment2 from deleted;
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'Comment2', @Value, '';

            select @Value=Notes from deleted;
            exec wnf_InsertAuditRecord 'D', @RowId, 'EmployeeLearningNeeds', 'Notes', @Value, '';
end

非常感谢,

正如 Aaron 在评论中所说,这只是 Intellisense 中的一个转移注意力的问题。