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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Delete after insert

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2008-06-24 : 10:35:07

Using OrderRebate Table.

Have two records getting inserted. All fields are identical except for cd_tp.

If 2 records are inserted I would like the record with cd_tp 3 deleted.

Code below doesn't seem to be working


delete orderrebate
FROM OrderRebate inner join inserted on inserted.ord_type = OrderRebate.ord_type and
inserted.ord_no = OrderRebate.ord_no and inserted.line_seq_no = OrderRebate.line_seq_no
where inserted.ord_type = OrderRebate.ord_type and inserted.ord_no = OrderRebate.ord_no
and inserted.line_seq_no = OrderRebate.line_seq_no and inserted.cd_tp = '3'
END

Vack
Aged Yak Warrior

530 Posts

Posted - 2008-06-24 : 10:56:13
Figured this out.
Had the wrong syntax by my create trigger statment. Had for delete instead of after insert. Once I put After Insert it worked.
Go to Top of Page
   

- Advertisement -