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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL 2000 - BEFORE Update Trigger?

Status
Not open for further replies.

robertfah

Programmer
Mar 20, 2006
380
US
I've got a table that is controled by a 3rd party software. I need to be able to copy the contents of this table to another table BEFORE any updates happen. So basically, I would have a copy of the OLD table data in one table and the current data in another.

Any ideas?
 
You can just use a regular trigger and copy the data from the deleted table to the copy of the original.

Something like:

Code:
Insert Into MySavedDateTable
Select *
From   deleted

You may want to add additional information like username and DateTime to this code. In the "MySavedDataTable", add a couple columns and then.

Code:
Insert Into MySavedDateTable
Select *, suser_sname(), GetDate()
From   deleted


I would encourage you to test this on a "Test" table first to make sure it does what you want it to.


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top