1

I need to audit DDL changes made to a database. Those changes need to be replicated in many other databases at a later time. I found here that one can enable DDL triggers to keep track of DDL activities, and that works great for create table and drop table operations, because the trigger gets the T-SQL that was executed, and I can happily store it somewhere and simply execute it on the other servers later.

The problem I'm having is with alter operations: when a column name is changed from Management Studio, the event that is produced doesn't contain any information about columns! It just says the table was locked... What's more, if many columns are changed at once (say, column foo => oof, and also, column bar => rab) the event is fired only once!

My poor man's solution would be to have a table to store the structure of the table that's going to be altered, before and after the alter operation. That way, I could compare both structures and figure out what happened to which column(s).

But before I do that, I was wondering if it is possible to do it using some other feature from SQL Server that I have overlooked, or maybe there's a better way. How would you go about this?

AdamL
  • 12,421
  • 5
  • 50
  • 74
ferc
  • 560
  • 6
  • 21
  • "http://technet.microsoft.com/en-us/library/bb522542(v=sql.105).aspx" here you will find all ddl event you can track. if changes happen from SSMS then it can not controlled in DDL trigger. instead write server level trigger to only allow changes using t-sql commands. – Anup Shah Oct 31 '13 at 02:03
  • The link appears to be broken... And I'm afraid I cannot forbid users to modify tables from SSMS... – ferc Oct 31 '13 at 15:46

2 Answers2

0

There is a product meant for doing just that (I wrote it).
It monitors scripts that contained ddl changes, who wrote them and when together with their effect on performance, and it gives you the ability to easily copy them as one deployment script. For what you asked, the free version is sufficient.
http://www.seracode.com/

Yuval Perelman
  • 4,499
  • 1
  • 22
  • 32
-1

There is no special feature in SQL Server regarding your need. You can use triggers, but they require a lot of T-SQL coding for proper function. Fast solution would be some third party tools, but they're not free. Please take a look at this answer regarding the third party tools https://stackoverflow.com/a/18850705/2808398

Community
  • 1
  • 1
Marko Krstic
  • 629
  • 6
  • 5