Triggers

  • Is there any way, in a trigger, to access the name of the stored procedure that caused the trigger to fire?  @@procid returns the trigger id, not the calling procedure.  If a certain stored procedure causes the trigger to fire ( a monthly maintenance job) I want to exit the trigger without doing anything.

    Terri

    tsanta@lsuhsc.edu



    Terri

    To speak algebraically, Mr. M. is execrable, but Mr. C. is
    (x+1)-ecrable.
    Edgar Allan Poe
    [Discussing fellow writers Cornelius Mathews and William Ellery Channing.]

  • With the function app_name() you can know if the trigger is being called by a job.

    the result is that is being called by SQL Agent and also is gives you the id of the job. If you can capture the id then you can know what job is it.

  • Thanks for the quick responses.  The article by Andy Warren was particularly helpfull.  I've decided to use the SET CONTENT_INFO solution for now.

    Terri

    tsanta@lsuhsc.edu



    Terri

    To speak algebraically, Mr. M. is execrable, but Mr. C. is
    (x+1)-ecrable.
    Edgar Allan Poe
    [Discussing fellow writers Cornelius Mathews and William Ellery Channing.]

  • This works Beautifully:

    DBCC INPUTBUFFER(@@spid)

    It will return the sproc name or the query string (if uncompiled)

    Signature is NULL

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply