Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

track database changes

Posted on 2010-11-24
4
Medium Priority
?
350 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 500 total points
ID: 34203375
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 500 total points
ID: 34203377
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 500 total points
ID: 34203386
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 500 total points
ID: 34203971
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

926 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