What are magic tables?
Akhil Mittal
Magic tables are logical tables which are managed internally by SQL Server. In every DML operations first data move into these tables. "INSERTED" and "DELETED" are tables names for magic table. We can't access these tables except in trigger.
Magic tables are nothing but inserted and deleted which are temporary object created by server internally to hold the recently inserted values in the case of insert and to hold recently deleted values in the case of delete, to hold before updating values or after updating values in the case of update
Deleted and Inserted are the magic tables in the sql server. These magic tables are used in the triggers to get the inserted and deleted values.
Magic tables are used by mostly triggers in SQL Server. DML Language uses these table to store data tempararey.
Often we need to know about the data which is inserted/deleted by the triggers in database. With the insertion and deletion of data, tables named “INSERTED” and “DELETED” automatically gets created in SQL Server which contains modified/deleted data. These “INSERTED” and “DELETED” tables are called magic tables.