whats the name of the sproc?

  • I want to write an update trigger on a table that inserts into a debug table whenever a particular field in my table gets updated by the many different sprocs I use to do updates. How can I capture the name of the sproc that has updated the field in the table and insert that name into my debug table using the trigger?

  • R, can you reference the @@PROCID global variable in the INSERT statement within the trigger?

     
    
    INSERT INTO <logtable>
    (
    <stuff>,
    SprocName,
    <morestuff>
    )
    VALUES (
    <stuff>,
    OBJECT_NAME(@@PROCID),
    <morestuff>
    )

    SJTerrill

    P.S. I'm wondering if there's another, perhaps more easily managed, method to perform this trick. Perhaps a stored proc that gets called from within your stored procs that perform these tasks... and pass that proc the current OBJECT_NAME(@@PROCID) value. I'd be interested in what the resident gurus think!

Viewing 2 posts - 1 through 1 (of 1 total)

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