• ScottPletcher - Tuesday, March 28, 2017 12:31 PM

    The trigger would still fire, but you could have it immediately exit.  The easiest way is likely using CONTEXT_INFO.  Have the app set the first two bytes of it to some unusual value, say 0xFEDC.  The trigger checks that first: if it's set, the trigger immediately exits.  Something like below.  You could also check the APP_NAME() for a given string, assuming your application sets the name, or you could cause it to set the name.

    In the app:
    --at_start_of_app_code
    SET CONTEXT_INFO 0xFEDC
    --other_app_code
    --at_end_of_app_code
    SET CONTEXT_INFO 0x0000

    In the trigger:
    CREATE TRIGGER ...
    AS
    IF SUBSTRING(CONTEXT_INFO(), 1, 2) = 0xFEDC
        RETURN;
    --rest_of_trigger_code

    This is the option I generally use. The application passes a context_info and if it matches we have it exit.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events