Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: Get trigger name inside trigger (reflection) Date: Thu, 24 Nov 2011 08:14:35 +0000 (UTC) Organization: Erland Sommarskog Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Thu, 24 Nov 2011 08:14:35 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="G7+Jz22XqYCG8C6rb1H3YA"; logging-data="9895"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186fEP9eb3H6ovXdNWMn5w8" User-Agent: Xnews/2005.10.03 Mime-proxy/1.4.c.4 (Win32) Cancel-Lock: sha1:CirEmtWOwGUr/pwOSsLBHxHKnA4= Xref: x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:834 Necoc Yaotl (tezcatlipoca1427@gmail.com) writes: > Inside a trigger, is there a way to get the name of that trigger? (in > SQL Server 2000). > > Something like: > > create trigger my_trigger on my_table for update > as > > declare @current_trigger_name varchar(100) > > select @current_trigger_name = some_function() You can use @@procid which returns the object id for the currently runnnig module which you can pass as a parameter. You can then use the function object_name() to get the name of the trigger. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx