Hi,
I want to know that what is magic table and role of magic table in the database ?
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Feb 28, 2012, 9:55 AM
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
Jignesh TrivediPosted Feb 28, 2012, 5:08 AM
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.
Satyapriya NayakPosted Feb 26, 2012, 3:40 AM
Please refer the below link
http://vishalnayan.wordpress.com/2011/04/14/what-is-magic-table-in-sql-server/
Thanks