Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table Name from within Trigger

Author  Topic 

EarlXT
Starting Member

10 Posts

Posted - 2009-07-07 : 10:47:06
I am creating a trigger that must be applyed to all my tables and I would like to get the Table Name form within the trigger so I don't have to type it in for every trigger. Is there a way to do this without manually supplying any information to the trigger? If I can even get the trigger name, I can extract the table name from that.

Thanks for your help

Earl

EarlXT

NeilG
Aged Yak Warrior

530 Posts

Posted - 2009-07-07 : 11:20:53
what are you actually trying to carry out with this
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-08 : 12:45:13
dont think there's a direct way of doing this
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-08 : 13:25:26
I've never tried this myself (that's what code generators are for). But, there are a bunch of Metadata Functions (search for that in BOL).

You might be able to get the name using a combination of Metadata functions like OBJECT_NAME() and @@ProcID. @@ProcID will return the ID of a stored procedure, user-defined function, or trigger.
Go to Top of Page
   

- Advertisement -