Tuesday 8 August 2017

INSERTED and DELETED Logical Tables in Sql Server

Where we are using Trigger for DML it use Inserted and Deleted magic table. Which is not visible It is created on temp database.

http://bageshkumarbagi-msbi.blogspot.in/2017/08/trigger-in-sql-server.html

Data Manipulation Language (DML) Triggers have access to the two special logical Tables named INSERTED and DELETED. These are the temporary tables managed by Sql Server. Structure of these tables will be same as that of the table on which the DML action is fired and holds the old and new values of the rows which are modified by the DML statement.
DELETED logical table will hold the rows which are deleted from the trigger table (i.e. the table on which the trigger is defined) by the DELETE or UPDATE operation. An UPDATE DML operation is internally executed as first the deletion of the existing record and then insertion of the new record.INSERTED logical table will hold the rows which are inserted by the INSERT and UPDATE statement.

Below table depicts the contents of the INSERTED and DELETED logical tables for three DML operations

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts