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 12345»»»

Monitoring Changes in Your Database Using DDL Triggers Expand / Collapse
Author
Message
Posted Thursday, October 2, 2008 12:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: 2 days ago @ 12:28 PM
Points: 7, Visits: 262
Comments posted to this topic are about the item Monitoring Changes in Your Database Using DDL Triggers
Post #579492
Posted Thursday, October 2, 2008 12:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 7, 2008 2:28 AM
Points: 7, Visits: 15
This is exactly why I use this site. Simple clear solutions that genuinely add some value to the products I develop. Although, I had to rename the objects (BlameMeTrigger and BlameMeLog). I think this will convey my intentions clearly enough ;¬).

I look forward to the next installment.
Post #579499
Posted Thursday, October 2, 2008 1:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, December 2, 2008 9:36 AM
Points: 5, Visits: 13
Hi,

I surly join the post saying that this site is the best!.

Though - i have a question - anyone investigated the DB performance issue? My concern is that if I will use the solution detailed here in a DB that is widely used, the DDL will affect the DB response time.

What do you think?

Uzi
Post #579507
Posted Thursday, October 2, 2008 3:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 28, 2009 6:22 AM
Points: 8, Visits: 63
I upgraded my SQL2000 to SQL2005 and all of the triggers were fine after the upgrade. Then my vendor provided an upgrade to the ERP which blew away a couple of the triggers on a custom table I had in the database. This has happened before. I simply re-created the triggers as I had done before when we were on SQL2000. Except now, on SQL2005, the triggers won't work. I am creating them in SSMS, logged on as 'sa'. The error message that the user gets is that she is not able to access the server. I've certainly experienced permission problems when I create SSIS packages. Could this be the same kind of problem? I find it difficult to figure out what is wrong with triggers. Any ideas about what I can do?
Post #579531
Posted Thursday, October 2, 2008 4:29 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, January 2, 2013 12:15 PM
Points: 1,443, Visits: 711
David,
Excellent article - concise and to the point! Well done!

Mark
Post #579548
Posted Thursday, October 2, 2008 6:00 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 10:12 AM
Points: 1,166, Visits: 1,973
Something to keep in mind ... the connection making a change, has to have access to the audit table. That and unless you want to create an audit table per database, it's usually best to use a central table per server.

Check the attached for a script that will push the trigger to all databases. The trigger is more or less the same, but also catches the application. Change the @LoggingDBName to whatever you use for your central DBA/Logging/Admin database.

As stated though, make sure your logins have write access to the changelog table.


---
SQLSlayer
Making SQL do what we want it to do.



  Post Attachments 
2005.DDLChange_trg.txt (43 views, 3.31 KB)
Post #579587
Posted Thursday, October 2, 2008 6:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, July 30, 2010 9:23 AM
Points: 9, Visits: 20
In my environment I have 20 databases that are constantly updated 24 hours a day. The application uses one user account so my question has two parts.

1. Can I exclude this user from the trigger?

2. With changes being made constantly is there a way to keep the table size down?
Post #579609
Posted Thursday, October 2, 2008 6:54 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Saturday, September 27, 2014 12:26 PM
Points: 676, Visits: 433
Steven Mann (10/2/2008)
In my environment I have 20 databases that are constantly updated 24 hours a day. The application uses one user account so my question has two parts.

1. Can I exclude this user from the trigger?

2. With changes being made constantly is there a way to keep the table size down?


1) In your trigger you can check the login name
SET @loginname = @data.value('(/EVENT_INSTANCE/LoginName)[1]',
'NVARCHAR(100)')
....

IF @loginname != 'appuser'
BEGIN
-- do the work
END

2) You can implement a job that does cleanup on a regular basis.

We just recently implemented this in our three main databases for one of our applications, logging to a central table (yes Adam, user has the rights =) ) just in our dev environment (we have a strict dev->qa->production process so we really just need to identify/validate which objects need to be pushed for a release). We have not had an opportunity to use it just yet, but seems to be working fine with the testing we have done.



Post #579612
Posted Thursday, October 2, 2008 7:01 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 3:44 AM
Points: 1,260, Visits: 3,424
Nice one ... I like it, is very simple!

;)


============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #579617
Posted Thursday, October 2, 2008 7:22 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, October 27, 2014 6:49 AM
Points: 1,585, Visits: 1,859
David,
Thanks for the elegant trigger, perfect for keeping an eye on those rogue developers! (like me -- hey, wait a minute ...) ;)
Post #579632
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse