Question

Background I have a production SQL Server 2005 server to which 4 different applications connect and make changes. There are no foreign keys and in some cases no primary keys. Unfortunately throwing the whole thing out and starting from scratch is not an option. So my solution is to start migrating each of the applications to a service layer approach so that there is only one application directly connecting to the database.

However there are problems that need to be fixed before that service layer is written and all the applications are migrated over.

So rather than make changes and hope they don't break any one of the 4 badly written applications (with no way of quickly testing all functionality) my solution is to start auditing the database

Problem How do I audit what stored procedures, tables, columns, views are being accessed/updated/called by each user on SQL Server 2005.

I can find out which tables are being updated but I have no idea which columns and by what users. I also don't know if certain tables are being accessed only through stored procedures/views.

I know that SQL Server 2008 has better auditing features but if I could do this without spending money that would be great. That said if the best solution is to upgrade or buy software that's also an option.

Was it helpful?

Solution

Check out SQL Server 2008's CDC feature. You can't use this directly in 2005 but you can write a trigger for each table to log all data changes to a new audit table. i.e. you'd have an audit table for each table in your db, with all the same columns plus some additional columns saying what the operation was and when it occurred.

If the nature of your applications means you can get user information and/or application information from CURRENT_USER and APP_NAME() you could include that information in the audit table too.

And check out this answer for more goodness.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top