Solved

track database changes

Posted on 2010-11-24
4
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 125 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 125 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 125 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 125 total points
ID: 34203971
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

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…
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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