Magic Tables
Magic tables are nothing but the logical tables maintained by SQL server internally.
There are two types of Magic tables available in SQL server:
Inserted
Deleted
We can not see or access these tables directly, not even their data-type. The only method to have access to these tables is Triggers operation either After Trigger or Instead of trigger.
Inserting into Table (Inserted Table):
Whenever we do insert anything in our base table in database, a table gets created automatically by the
SQL server, named as INSERTED. In this table current updated or inserted record will be available. we can access this table of record via triggers.
Updating Table (Inserted & Deleted Table):
Whenever we do any deletion operation on our base table, in spite of one, two tables are created, one is INSERTED and another is called DELETED. Deleted table consist of the current record after the deletion operation and Inserted table consists of the previous record. We can access it via Triggers functionality.
Deleting (Deleted Table):
Whenever we do deletion in base table in database, a table gets created automatically by the SQL server, named as
DELETED table. This table consist of current updated record after deletion operation. Again we can have access to these records via triggers.