Hi,
I want to know that what is magic table and role of magic table in the database ?
Thanks
Magic Table
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 25, 2012, 10:40 PM EST
Please refer the below link
http://vishalnayan.wordpress.com/2011/04/14/what-is-magic-table-in-sql-server/
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 28, 2012, 12:08 AM EST
Magic tables are nothing but INSERTED, DELETED table scope level, These are not physical tables, only Internal tables.
Magic tables are referenced in triggers and contain the inserted and deleted data for reuse.
please refer.
http://www.dotnetspider.com/resources/29332-Magic-tables-SQL-Server.aspx
hope this help.
SenthilkumarRank #387 · 6.5K reputationPosted Feb 28, 2012, 4:55 AM EST
Magic tables are the logical tables in the sql server which is used at the time of DML.
When you do the transaction then the inserted/updated/deleted records can be rolled back to the previous state of the table.
Then sql server uses the inbuilt table to keep the records.
There are two tables.
INSERTED
DELETED
There is no table for the UPDATE. But what sql server does when you update, it deletes the records and it inserts again a new record.
You can query the record from the magic tables.
Insertion check ---> SELECT * FROM INSERTED
Deletion check ---> SELECT * FROM DELETED
Updation check ---> SELECT COUNT(*) FROM INSERTED > 0 AND SELECT COUNT(*) FROM DELETED > 0