Saleh
Saleh

Reputation: 2719

How I can track all changes that made to database and save them for review?

I am building an application that users can add, update data.

Is there any way to track changes to a database and save these tracks in file or in another database for example.

Thanks in advance.

Upvotes: 2

Views: 2022

Answers (4)

Steve Wellens
Steve Wellens

Reputation: 20620

I've never tried them but there are built in tools and utilities:

SQL Server Change Tracking

Upvotes: 1

Divi
Divi

Reputation: 7691

We currently use Audit tables to do this. So for every "Table" there is a corresponding "Table_AT" and there are triggers for every CRUD operation. So, on any CRUD function, the new data is written to the audit table.

This link has examples http://web.archive.org/web/20071006100909/http://sqlserver2000.databases.aspfaq.com:80/how-do-i-audit-changes-to-sql-server-data.html

Upvotes: 0

slugster
slugster

Reputation: 49974

You can use triggers on the tables you want to track, and with those triggers you can determine which fields have changed (or if a record has been inserted or deleted), and then write the appropriate entry to an audit table.

Here is one article i found after a real quick search... Adding simple trigger-based auditing to your SQL Server database (Googling on the keywords sql server trigger audit should bring you mucho satisfaction and knowledge).

Upvotes: 0

Alex
Alex

Reputation: 66

In SQL Server, there's Query Profiler which can run a trace against a live database and log all the queries to another database or a file

http://msdn.microsoft.com/en-us/library/ms187929.aspx

Upvotes: 0

Related Questions