1
I have a Rigger that fires when it is Insert/update FOR UPDATE, INSERT
I check if the field was changed with:
if update (nome)
--faça algo
How do I know if I am entering a record in the table to record a log?
1
I have a Rigger that fires when it is Insert/update FOR UPDATE, INSERT
I check if the field was changed with:
if update (nome)
--faça algo
How do I know if I am entering a record in the table to record a log?
2
Jeterson, I have more knowledge in Oracle, but searching a little with key terms, I believe it will solve your problem.
SQL_STATEMENT
It is the conditions and actions of the trigger. The trigger conditions specify additional criteria that determine whether the DML, DDL or logon events cause trigger actions to be executed.
A trigger is created to verify or change data based on a definition statement or data modification. It should not return user data.
DML triggers use logic tables (conceptual)
deleted
andinserted
.
In accordance with Documentation - CREATE TRIGGER (Transact-SQL)
The table
deleted
stores copies of affected lines during instructionsDELETE
andUPDATE
. During the execution of an instructionDELETE
orUPDATE
, lines are excluded from the triggers table and transferred to the tabledeleted
. The tabledeleted
and the table of triggers usually have no lines in common.
In accordance with Documentation - Use inserted and deleted tables (Transact-SQL)
As documentation, to know if you are entering a record, you can do as follows:
IF EXISTS (SELECT 1 FROM deleted)
-- update
Browser other questions tagged sql database sql-server
You are not signed in. Login or sign up in order to post.
Oops, it came out right, I checked it this way:
IF NOT EXISTS (SELECT * FROM DELETED)
. Thanks.– Jeterson Miranda Gomes