Groups | Blog | Home
all groups > sql server programming > january 2007 >

sql server programming : trigger order info



David Portas
1/7/2007 4:00:15 PM
[quoted text, click to view]

Trigger order is undefined except for the first and last triggers to
fire for each DML statement. Take a look at the OBJECTPROPERTY function
in Books Online. You'll see that there are separate properties for each
case. Example:

OBJECTPROPERTY(id,'ExecIsFirstDeleteTrigger')

In SQL Server 2005 you can use the sys.trigger_events catalog view
instead.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
wapsiii NO[at]SPAM otmail.com
1/7/2007 11:23:47 PM
How can I query info about the current trigger execution order? (set
Erland Sommarskog
1/8/2007 12:02:00 AM
wapsiii@otmail.com (wapsiii@otmail.com) writes:
[quoted text, click to view]

Look at the objectproperty() function. There are a couple of properties
starting with Exec that are of interest to you.


--
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
Morten71
1/8/2007 1:01:12 PM
On Sun, 07 Jan 2007 23:23:47 -0800, "wapsiii@otmail.com"
[quoted text, click to view]
DECLARE @id AS INT,@objectName AS NVARCHAR(128)
SET @objectName = N'dbo.triggerA'
SELECT @id = OBJECT_ID(@objectName)
SELECT OBJECTPROPERTY(@id, 'ExecIsFirstDeleteTrigger') AS
ExecIsFirstDeleteTrigger,
OBJECTPROPERTY(@id, 'ExecIsFirstUpdateTrigger') AS
ExecIsFirstUpdateTrigger,
OBJECTPROPERTY(@id, 'ExecIsFirstInsertTrigger') AS
ExecIsFirstInsertTrigger,
OBJECTPROPERTY(@id, 'ExecIsLastDeleteTrigger') AS
ExecIsLastDeleteTrigger,
OBJECTPROPERTY(@id, 'ExecIsLastUpdateTrigger') AS
ExecIsLastUpdateTrigger,
OBJECTPROPERTY(@id, 'ExecIsLastInsertTrigger') AS
AddThis Social Bookmark Button