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 |
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2004-08-10 : 16:33:39
|
| Hi, I have gone though the examples and I am still confused.I have 2 tables, T1 and T2 T1 = (recordID,data1,data2)T2 = (data1,data2)Basically, when a row is entered into T1, or updated, I want the previous state of the row (data1 and data2) to be stored in T2. I can't seem to get a trigger for this to work.I haveCREATE TRIGGER [Trigger] ON [dbo].[Table_1] FOR INSERT, UPDATEASINSERT INTO Table_2 (data1,data2) SELECT data1,data2 FROM Table_1 WHERETable_1.RecordID = RecordIDI know, its probably way off.thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-08-10 : 17:15:41
|
| For inserts, there is no previous state. Right? For updates:CREATE TRIGGER [Trigger] ON [dbo].[Table_1]FOR UPDATEASINSERT INTO Table_2 (data1,data2) SELECT data1,data2 FROM deleteddeleted table contains the old information. inserted table would contain the new information.Tara |
 |
|
|
|
|
|
|
|