CREATE TRIGGER TEST on dbo.CATEGORY
FOR INSERT, UPDATE
AS
insert into category_audit(category_code, category_name,
date_updated)
select c.category_code, c.category_name, c.date_updated
from category c, inserted i
where c.category_code = i.category_code
GO
on second thoughts you could rpobably just query the inserted tables straight like so:
insert into category_audit(category_code, category_name,
date_updated)
select category_code, category_name, date_updated
from inserted
the inserted table stores the current changed row while the trigger executes so you might be able to avoid the join.
if update(column A)
insert into category_audit(category_code, category_name,
date_updated)
select c.category_code, c.category_name, c.date_updated
from category c, inserted i
where c.category_code = i.category_code
GO
if you want to record new records inserted which would affect column A then change it to a FOR INSERT, UPDATE trigger.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.