Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to track if there are changes in the database

Status
Not open for further replies.

uhu

IS-IT--Management
May 21, 2003
40
NZ
Hi everyone,

Is there a tool/software or a way to track changes (insert,update,delete) in the database ?

In my situation, I'm trying to find out, what field(s) from which table(s) changes after I executed something in my program. I need to know, what changes in the database has been made (from what value to what value, etc).

Thanks in advance

vito
 
The best way would be to create a trigger on the tables you want to monitor. You can set a trigger to fire anytime a change is made to the table (insert, update, delete). What I usually do is create another table to hold the info I want to record, and then have the trigger put the info in that table. For example, if I wanted to track the date and time a change was made to a record in Table A, I would set up a trigger on Table A to insert the date and time (and probably the changed record ID) into Table B every time a change was made.

Like this:

CREATE TRIGGER [Create_History] ON dbo.TableA
FOR INSERT, UPDATE, DELETE
AS

INSERT INTO TableB (ItemID, DateTime)
SELECT ItemID, getDate()
FROM Inserted

Pretty basic example but it should get you started.

 
Thanks for ur help Eccob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top