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 2000 Forums
 SQL Server Development (2000)
 triggers

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-28 : 09:08:35
jonathan writes "hi!i made an insert trigger which i attached below.What should i add to this trigger to make my audit table(my table that logs the modification made in my trigger table)log only modification made manually and not those generatted by the system because we have a table that inserts row every transaction(meaning transactional modification)?Pls help me on this!Thanks!

create trigger insert_trigger
on ShiftLog
for insert
not for replication
as
begin
insert into audit_ShiftLog
(log_type,
StationID,
OperatorID,
Logon,
Logoff,
exception_cnt,
DeleteFlg,
action)

select 'OLD',

del.StationID,
del.OperatorID,
del.Logon,
del.Logoff,
del.exception_cnt,
del.DeleteFlg,
'INSERT'
from deleted del

insert into audit_ShiftLog
(log_type,
StationID,
OperatorID,
Logon,
Logoff,
exception_cnt,
DeleteFlg,
action)
select 'NEW',
ins.StationID,
ins.OperatorID,
ins.Logon,
ins.Logoff,
ins.exception_cnt,
ins.DeleteFlg,
'INSERTED'
from inserted ins
end


"
   

- Advertisement -