The trigger is defined to fire on insert, but you execute an update.
SQL Server 2019 trigger does not execute
I just moved a database from sql server 2014 to 2019 and now an update trigger does not execute when it should. Here's the first part of the trigger:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[UTrig_Customer]
ON [dbo].[tbCustomer]
AFTER INSERT
AS
DECLARE
@Cust_Id uniqueidentifier,
@auditAction_Id uniqueidentifier
BEGIN
SET NOCOUNT ON;
Bla bla bla...
and the trigger is enabled.
This trigger should insert a row into an audit table, which does not happen. also, when I execute an update statement from the SSDT debugger it does not step into the trigger:
UPDATE tbCustomer
SET
Cust_Name = @Cust_Name,
Cust_Code = @Cust_Code,
Cust_CustTp_Id = @Cust_CustTp_Id,
Cust_Discount = @Cust_Discount,
Cust_St_Id = @Cust_St_Id,
Cust_Cnt_Id = @Cust_Cnt_Id,
Id_Rank = @Id_Rank,
Cust_Notes = @Cust_Notes,
Cust_IsActiveRow = @Cust_IsActiveRow,
Cust_UserId = @Cust_UserId,
Cust_LastModifiedDate = GETDATE(),
Cust_auditAction_Id = @auditAction_Id
WHERE (Cust_Id=@Cust_Id)
any idea why this does not work?
SQL Server | Other
2 answers
Sort by: Most helpful
-
Cris Zhan-MSFT 6,676 Reputation points
2020-08-20T03:41:11.91+00:00 Hi,
If the trigger in this database worked normally before, but it does not work after upgrading this database, so this may be related to the database upgrade.
Have you changed the compatibility level of the database, set it to SQL Server 2019 (150).===============================================
If the response helped, do "Accept Answer" and upvote it.