A trigger which inserts into table A from 2 tables B and C.
TableA data looks like
1001 38488 JAMES King 2006-11-29 07:56:45.000
2002 38488 JAMES King 2006-07-18 08:23:59.000
3003 38488 JAMES King 2006-08-14 09:22:14.000
Here in TableA i want delete rows except most recent row 1001 --.
Need to include the delete query after insert rows in below trigger.pls advice.Thanks.
CREATE TRIGGER [trig1] ON tableB
FOR INSERT,DELETE
AS
begin
insert into tableA(item_num,emp_id,emp_name,tran_date)
select
a.item_num,
a.emp_id,
c.emp_name,
max(a.start_tran_date)
from tableB a,tableC c where
a.emp_id=b.emp_id
group by a.item_num,
a.emp_id,
c.emp_name
end
TableA data looks like
1001 38488 JAMES King 2006-11-29 07:56:45.000
2002 38488 JAMES King 2006-07-18 08:23:59.000
3003 38488 JAMES King 2006-08-14 09:22:14.000
Here in TableA i want delete rows except most recent row 1001 --.
Need to include the delete query after insert rows in below trigger.pls advice.Thanks.
CREATE TRIGGER [trig1] ON tableB
FOR INSERT,DELETE
AS
begin
insert into tableA(item_num,emp_id,emp_name,tran_date)
select
a.item_num,
a.emp_id,
c.emp_name,
max(a.start_tran_date)
from tableB a,tableC c where
a.emp_id=b.emp_id
group by a.item_num,
a.emp_id,
c.emp_name
end