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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-11 : 00:44:54
|
| Anthony writes "I want to be able to duplicate every single record that is inserted or updated in a particular table to another table, but not the delete. Is the best way to set-up a trigger? If so can you provide me with an example of how to do this? Also could you just duplicate certain columns in the row I would you have to do all columns?Thanks for help." |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-03-11 : 07:45:35
|
| IMHO , triggers will be good , if you are lookign for a immediate insertion of records. but if you can wait after a specific time. then you can create a DTS package and Schedule it using Job scheduling wizard or sp_add_job ,sp_add_jobschedule.Remember Triggers have a high precedence for execution. if you are inserting couple of thousand records every hour and will use the audit table on periodic basis then its better to DTS it. CREATE TRIGGER upd_trg ON [dbo].[tt] FOR UPDATEASinsert into tt1 select a,b from insertedgoCREATE TRIGGER ins_replic_Tt ON [dbo].[tt] FOR INSERTASinsert into tt1 select a,b from insertedgoYou can filter your select for the specific columns you want to inserteg:CREATE TRIGGER ins_replic_Tt ON [dbo].[tt] FOR INSERTASinsert into tt1(a1) select a from insertedgo-------------------------------------------------------------- |
 |
|
|
|
|
|