Let us suppose if we write a trigger on the table on insert or delete or update. So on insertion of a record into that table, the inserted table will be created automatically by the database, on deletion of record from that table; the deleted table will be created automatically by the database.
2. These two tables, inserted and deleted, are called magic tables.
3. Magic tables are used to put all the deleted and updated rows. We can retrieve the column values from the deleted rows using the keyword "deleted".
4. These are not physical tables, only internal tables.
5. This Magic table is used In SQL Server 6.5, 7.0 & 2000 versions with Triggers only.
6. But, In SQL Server 2005, 2008 & 2008 R2 Versions can use these Magic tables with Triggers and Non-Triggers also.
7. Using with Triggers:
If you have implemented any trigger for any Tables then,
- Whenever you insert a record into a table, that record will be in the INSERTED Magic table.
- Whenever you update the record in that table, that existing record will be in the DELETED Magic table and the modified new data with be in the INSERTED Magic table.
- Whenever you delete a record in that table, that record will be in the DELETED Magic table only.
These magic tables are used inside the Triggers for tracking the data transaction.
8. Using Non-Triggers:
You can also use the Magic tables with Non-Trigger activities using OUTPUT Clause in SQL Server 2005, 2008 & 2008 R2 versions.

SubashPosted Sep 16, 2016, 12:41 AM
Good share
Jaypee HudaPosted Nov 14, 2011, 5:53 AM
Hi Vishal Nayan, I was reading your article and I would like to appreciate you for making it very simple and understandable. This article gives me a basic idea of Magic Table in SQL Server and it will help me a lot. I had found another nice post over internet related to this post, which also explain nicely, Here I want to share the link of that post... http://mindstick.com/Blog/211/Magic%20Table%20in%20SQL%20Server So I would like to say thanks to everyone and keep it up. Thank you very much!
Vishal NayanPosted Apr 30, 2011, 8:51 AM
i was asked this question in an interview. So i thought to spread it :)
Vishal NayanPosted Apr 30, 2011, 8:50 AM
i was asked this question in an interview. So i thought to spread it :)
Mahesh ChandPosted Apr 30, 2011, 8:38 AM
Correct. I did not know this either.
Prafull ShrivastavaPosted Apr 30, 2011, 5:59 AM
This post is so much interesting with this i learn new concept of database....