Collections:
"INSERTED" - New Record of an DML Event Instance in SQL Server
How To Access the Inserted Record of an Event in SQL Server?
✍: FYIcenter.com
When a DML event occurs, SQL Server will prepare a temporary table called "INSERTED", which contains the new record of the affected row, which is:
The tutorial exercise below shows you how to create a trigger, update_user, to report email changes on table, fyi_users:
USE FyiCenterData; GO DISABLE TRIGGER dml_message ON fyi_users; GO CREATE TRIGGER update_user ON fyi_users AFTER UPDATE AS DECLARE @new VARCHAR(80); SELECT @new = email FROM INSERTED; PRINT 'Email changed to '+@new; GO UPDATE fyi_users SET email='john@fyicenter' WHERE name = 'John King'; GO Email changed to john@fyicenter (1 row(s) affected)
As you can see, the INSERTED table is helpful, if you want the trigger to perform specific logics on the affected rows.
⇒ "DELETED" - Old Record of an DML Event Instance in SQL Server
⇐ sys.trigger_events - Event List of an Existing Trigger in SQL Server
2016-10-24, 2238🔥, 0💬
Popular Posts:
What are binary literals supported in SQL Server Transact-SQL? Binary literals in Transact-SQL are s...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Drop a Stored Procedure in Oracle? If there is an existing stored procedure and you don't wan...
How To Get the Definition of a User Defined Function Back in SQL Server Transact-SQL? If you want ge...
How To Convert Numeric Values to Integers in SQL Server Transact-SQL? Sometimes you need to round a ...