Home All Groups Group Topic Archive Search About

Which table launched the trigger

Author
13 May 2005 5:46 PM
Eduardo Martinez
Hi everyone,

Is there some way to know the name of the table that launched a trigger,
within the same trigger?

I'm trying to create code I can use with several tables without having to
modify it

Thanks in advance

Eduardo Martinez O.

Author
13 May 2005 5:53 PM
David Gugick
Eduardo Martinez wrote:
> Hi everyone,
>
> Is there some way to know the name of the table that launched a
> trigger, within the same trigger?
>
> I'm trying to create code I can use with several tables without
> having to modify it
>
> Thanks in advance
>
> Eduardo Martinez O.

You already have to create separate versions of the triggers for each
table. At that point, you're better off putting the table name directly
in the trigger. That's my recommendation. Another option might be to use
the @@PROCID variable along with OBJECT_NAME(). If you code your
triggers in a well-defined manner, you can probably pull the table name
from the trigger name. But I think that adds uncertainty and added
overhead to the trigger.

--
David Gugick
Imceda Software
www.imceda.com
Author
13 May 2005 6:16 PM
Eduardo Martinez
Thanks a lot, yes it seems the best option is to code the table's name
directly in the trigger,

Best regards

Eduardo Martinez O.


Show quote
"David Gugick" <davidg-nospam@imceda.com> escribió en el mensaje
news:O$BS2S%23VFHA.3280@TK2MSFTNGP09.phx.gbl...
> You already have to create separate versions of the triggers for each
> table. At that point, you're better off putting the table name directly
> in the trigger. That's my recommendation. Another option might be to use
> the @@PROCID variable along with OBJECT_NAME(). If you code your
> triggers in a well-defined manner, you can probably pull the table name
> from the trigger name. But I think that adds uncertainty and added
> overhead to the trigger.
>
> --
> David Gugick
> Imceda Software
> www.imceda.com
>

AddThis Social Bookmark Button