Triggers

  • Hi,

    I have set up a trigger on a table for handling data versioning. I am trying to make it as generic as possibly such that the procedure can be used for any table in the future.

    Is there any system variable / function which will give the name of the table on which the trigger has fired.

    Cheers

    Paul

  • Inside the trigger, the global variable @@procid will give you the object id for the trigger being executed.

    If you use that id to look up the sysobjects table (i.e. select * from sysobjects where id = @@procid), one of the columns in that table is parent_obj, which is the id for the table that the trigger belongs to. You can then use parent_obj to look up sysobjects to find the name of the table.

  • Thank you that has sorted the problem.

    cheers

    Paul

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

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