sp name in trigger

There are two different Stored Procedures insert data into a table, is it possible to catch what stored procedure name was that trigged the trigger in the trigger




Answer this question

sp name in trigger

  • scotsman60

    You could use the SET CONTEXT_INFO command to store the SP name in a connection wide context and then retrieve it from the trigger using a query on sysprocesses or CONTEXT_INFO() built-in in SQL Server 2005. See BOL on SET CONTEXT_INFO for more details. This will allow you to perform the check without modifying the schema. If you are on older versions of SQL Server like 70/65 then you can store the name in a temporary table or global cursor in the SPs and then retrieve it from the trigger code.

  • Mikael Gosen

    Hi,

    you can pass the procname as a column as information to the table, then the triger can leep track of the source of change. Otherwise there is no way to get this information.

    HTH, Jens Suessmeyer.

    ----
    http://www.sqlserver2005.de
    ----


  • sp name in trigger