What is Inserted, Deleted Logical table in SQL Server
304308-Nov-2015
Please explain me how to get inserted and deleted tables in sqlserver.
Updated on 08-Nov-2015
Home / DeveloperSection / Forums / What is Inserted, Deleted Logical table in SQL Server
Anonymous User
08-Nov-2015Sqlserver have Inserted and Deleted logical tables. These tables are automatically created and managed by SQL Server internally to hold recently inserted, deleted and updated values during DML operations (Insert,Update,Delete) on a database table.
Inserted logical Table
The Inserted table holds the recently inserted or updated values means new data values. Hence newly added and updated records are inserted into the Inserted table.
Suppose we have Employee table . Now We need to create two triggers to see data with in logical tables Inserted and Deleted.
Now insert a new record in Employee table to see data with in Inserted logical table.
Deleted logical Table
The Deleted table holds the recently deleted or updated values means old data values. Hence old updated and deleted records are inserted into the Deleted table.
We could not create the logical tables or modify the data with in the logical tables. Except triggers, When you use the OUTPUT clause in your query, logical tables are automatically created and managed by SQL Server. OUTPUT clause also has access to Inserted and Deleted logical tables just like triggers.