DECLARE @Action as char(1); SET @Action = (CASE WHEN EXISTS(SELECT * FROM INSERTED) AND EXISTS(SELECT * FROM DELETED) THEN 'U' -- Set Action to Updated. I finally found a line of text that talked about the fact that when a DELETE or UPDATE occurs, the common DELETED table will contain a record for these two actions.WHEN EXISTS(SELECT * FROM INSERTED) THEN 'I' -- Set Action to Insert. Based upon that information, I then created a small Action routine which determines why the trigger has been activated.
I need some help figuring out how to get my trigger to compile.i got this error master please help about this"Compilation failed, line 23 () The line numbers associated with compilation errors are relative to the first BEGIN statement. I am running into compilation issues with my trigger and am having trouble understanding how to create a trigger that references a sequence and another table, and insert those values into a log table that I've created.How would I go around writing it so that I can handle both Update and Insert cases. Table Name AFTER INSERT, UPDATE, DELETE AS BEGIN SET NOCOUNT ON; -- -- Check if this is an INSERT, UPDATE or DELETE Action.How would I determine if the trigger is executed for an update or insert. -- DECLARE @action as char(1); SET @action = 'I'; -- Set Action to Insert by default. In fact you can also use IF EXISTS(SELECT 1/0 ...) and it will still work and won't cause divide by zero error.