Triggers in SQL
-
Hi, Please help me... I ve 2 tables like one is 'emp' & other is copy of 'empc' Wht i want...whenever i update the emp table the old contents should be moved to the empc table & the new should be overwritten in the emp table... & i want all this should be done through a trigger...may be on update... but...this will overwrite the contains of emp...so wht should i do.... Thanks
-
Hi, Please help me... I ve 2 tables like one is 'emp' & other is copy of 'empc' Wht i want...whenever i update the emp table the old contents should be moved to the empc table & the new should be overwritten in the emp table... & i want all this should be done through a trigger...may be on update... but...this will overwrite the contains of emp...so wht should i do.... Thanks
hi you need something like this :
create trigger empCopyTrig on emp for Update as insert into empc Select * from deleted Go
try it..Waiting for feedback :)
-
Hi, Please help me... I ve 2 tables like one is 'emp' & other is copy of 'empc' Wht i want...whenever i update the emp table the old contents should be moved to the empc table & the new should be overwritten in the emp table... & i want all this should be done through a trigger...may be on update... but...this will overwrite the contains of emp...so wht should i do.... Thanks
When using triggers to update a table, the rows which will be affected by the update statement will be available in 'deleted' table and records with updated changes will be available in 'inserted' table. These two tables are available only during trigger execution and not outside the scope of a trigger. BK Bhaskara