Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 update log

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-15 : 09:02:53
Jesus writes "I want to keep track of the old value, new value, column updated and record identity every time a column is updated. This information will be saved in a log table. I'm using SQL 7"

mfemenel
Professor Frink

1421 Posts

Posted - 2002-01-15 : 09:40:42
You're going to want to read up on triggers and the inserted/deleted tables which are created when rows are updated/deleted/inserted. BOL will have a plenty of information for you.

You'll need to create a mirror table of your table where you're going to store the "log". Then on your primary table, create a trigger to fire when values are changed or records are deleted. When the trigger is fired, the inserted/deleted tables exist only for the transaction, you can then join insert from those tables into your log table and tag the column with a date/timestamp by using get date. That's an overview of what you'll need to do, but like I said, BOL will have more details on the inner workings. Post back here if you have questions.

Mike
"A program is a device used to convert data into error messages."
Go to Top of Page
   

- Advertisement -