Solved

track database changes

Posted on 2010-11-24
4
307 Views
Last Modified: 2012-06-27
How can i track changes in an sql server 2005 database?

For example, if I wanted to know the inserts,deletes and edits(original and after) that occurred in a certain day- how can i do that?
0
Comment
Question by:NormanMaina
4 Comments
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 125 total points
Comment Utility
The easiest way: create a datetime field in the table with default value to GETDATE(). So in each record saved, you will have the date and time it has been saved.

But that doesn't work for deletes, of course, because the deleted record is no longer in the database. For that case a good option is to use a Trigger for delete and track the date and time and the unique ID of the deleted record in another table.

If you want to know more about triggers, check this:
http://www.codeproject.com/KB/database/TriggersSqlServer.aspx

Hope that helps.
0
 
LVL 17

Assisted Solution

by:sweetfa2
sweetfa2 earned 125 total points
Comment Utility
create triggers to farm the data off to a data warehouse for the data that you are interested in.
0
 
LVL 16

Assisted Solution

by:EvilPostIt
EvilPostIt earned 125 total points
Comment Utility
In SQL Server 2008 there is CDC which i have included a link for, but i see you are using SQL Server 2005.

http://msdn.microsoft.com/en-us/library/bb522489(v=SQL.100).aspx

With SQL Server 2005 you will have to create triggers to insert the data into an audit table.
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 125 total points
Comment Utility
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now