March 7, 2008 at 6:31 am
insert into T2 select * from T1 where ;
delete from T1 where ;
You can put it into T1 trigger too, so you don't have to manually call the SP:
create trigger t1_xy on T1 for insert, update
as
insert into T2 select * from inserted where ;
delete from T1 join inserted on ;
Simple as that. Homework? exam question?
March 7, 2008 at 7:01 am
Actually, if you need to move the record from Table1 to Table2 on delete, you would use a trigger that fired ON DELETE to move the record.
😎
March 7, 2008 at 7:35 am
oops, of course. I reread the original post again. I should be more careful.
March 7, 2008 at 7:51 am
Use the OUTPUT clause from the DELETE statement to insert the data as it gets removed.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
March 7, 2008 at 7:54 am
Definately another way to do it. Haven't used it myself yet, but should look at when needed.
😎
Viewing 5 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply