SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trigger for delete and then insert into
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

learning_grsql
Posting Yak Master

218 Posts

Posted - 10/14/2012 :  17:38:41  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000