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.
Author |
Topic |
mike13
Posting Yak Master
219 Posts |
Posted - 2007-08-21 : 06:57:37
|
Hi,I was wondering if there is a easy way to do this.I got Table Customers, and when a row is changed, deleted, i want to copy the original row to a backup table, so i have the whole history.tnx a lot,Mike |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-08-21 : 22:39:00
|
You can use trigger. |
|
|
mike13
Posting Yak Master
219 Posts |
Posted - 2007-08-22 : 04:03:27
|
Okay, but how do i use a trigger (sorry never used them)tnx,Mike |
|
|
chadi_buddy
Starting Member
1 Post |
Posted - 2007-08-22 : 04:27:13
|
This is an example of creating a trigger. Just attach it to the table & you'll be good to go :)Trigger on an INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger)CREATE TRIGGER [ schema_name . ]trigger_name ON { table | view } [ WITH <dml_trigger_option> [ ,...n ] ]{ FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] } [ WITH APPEND ] [ NOT FOR REPLICATION ] AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME <method specifier [ ; ] > }<dml_trigger_option> ::= [ ENCRYPTION ] [ EXECUTE AS Clause ] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-22 : 04:50:39
|
quote: Originally posted by mike13 Okay, but how do i use a trigger (sorry never used them)tnx,Mike
Make use of sql server help fileMadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|