Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

can dml triggers statements get logged Expand / Collapse
Author
Message
Posted Monday, January 21, 2013 12:24 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 1:12 AM
Points: 82, Visits: 134
I want to understand since dml triggers are using data modification statements
are they logged in log file and if yes when?
and can we log those trigger events in auditing in system event log in sql 2008?
Post #1409373
Posted Monday, January 21, 2013 1:15 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, June 13, 2013 7:03 AM
Points: 2,562, Visits: 3,453
sej2008 (1/21/2013)
I want to understand since dml triggers are using data modification statements
are they logged in log file and if yes when?
i dont think they are differently/specially get treated for transational logging. their logging works same as other transactions.


-------Bhuvnesh----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #1409394
Posted Monday, January 21, 2013 4:58 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 2:46 AM
Points: 385, Visits: 1,418
USE [AdventureWorks];
GO

CREATE TABLE TestTrigger (ID INT)
GO
CREATE TABLE TestTriggerAudit (ID INT)
GO

CREATE TRIGGER trTestTrigger ON TestTrigger
FOR INSERT
AS
INSERT INTO TestTriggerAudit SELECT * FROM inserted;
GO

INSERT INTO TestTrigger VALUES (1);
GO

CHECKPOINT;

INSERT INTO TestTrigger VALUES (22);

DBCC LOG('AdventureWorks', 3);

DROP TABLE TestTrigger;
DROP TABLE TestTriggerAudit;



The SQL Guy @ blogspot

About Me


  Post Attachments 
TriggerLog.png (24 views, 6.36 KB)
Post #1409489
Posted Monday, January 21, 2013 7:46 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 1:12 AM
Points: 82, Visits: 134
Thanks I for your example it did help to understand practically.
Post #1409559
Posted Monday, January 21, 2013 7:47 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: 2 days ago @ 1:12 AM
Points: 82, Visits: 134
Thanks
Post #1409560
Posted Monday, January 21, 2013 7:55 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 3:25 AM
Points: 38,073, Visits: 30,366
sej2008 (1/21/2013)
I want to understand since dml triggers are using data modification statements
are they logged in log file and if yes when?
and can we log those trigger events in auditing in system event log in sql 2008?


Just one point...

The transaction log is not an audit log. It's not there so you can see what happened. If you want an audit log, then configure one using trace, extended events, CDC, change tracking or SQL Audit.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1409567
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse