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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trigger for delete and then insert into

Author  Topic 

learning_grsql
Posting Yak Master

230 Posts

Posted - 2012-10-14 : 17:38:41
I want to create a trigger for the following two codes in table2

First I want to delete table1 (it has 3 columns only).

Then I want to fill up the three columns values from table t which is an output by combining table2 and table3

Table3 is fixed table, Table2 data is deleted in every 3 days and added new data. Every time table2 is added with new data, I want table1 data should be deleted and the following codes to be run.




delete from table1


Second code

insert into table1
select field1, field2 field3 from
(select field1, field2, field3 from
table2
inner join table3 on table2.field2 = table3.field2)
as t
   

- Advertisement -