June 4, 2003 at 9:34 am
I am wondering if there is a @@ Global Variable that can be use in a trigger that will supply the name of the table being modified.
--------------------------------------------------------------------------------
James Taylor
Systems Engineer
E-mail: mailto:James.Taylor@fma.uk.com
--------------------------------------------------------------------------------
James Taylor
Systems Engineer
E-mail: mailto:James.Taylor@fma.uk.com
June 4, 2003 at 10:00 am
I don't think that it will exists. But you can query
select object_name(parent_obj)
from pubs.dbo.sysobjects
where xtype = 'TR'
AND Name = 'trigger_name'
TO know in witch table the trigger was define, but it doesn't mean that it is the name of the table been modified by the trigger.
June 4, 2003 at 8:22 pm
Not good enough, specially in the case where multi updates participate in same transaction.
Seem to be working in simple, single updates.
Need some more grey stuff + time!
CREATE TRIGGER Test_Trig ON [dbo].[Test] FOR INSERT, UPDATE, DELETE AS
Select Object_Name(id)
From Master..SysLocks
Where dbid=db_id() And
spid=@@SPID And
object_name(id) is Not NULL
June 5, 2003 at 8:31 am
Ive used the following to retrieve the table name;
declare @TbleName nvarchar(324)
SET @TbleName=(Select name from sysobjects where sysobjects.id = (select parent_obj from sysobjects where sysobjects.id =@@PROCID))
Of course then what you do with the @TblName value is up to you, throw it into a table somewhere, or a variable for later use.
Rick Brown
Rick Brown
June 5, 2003 at 4:23 pm
Thanks rbrow112, I just could not remember yesterday. Know it was quit uneventfull. Thanks!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply