what is a magic table in sql server
Prabhat Kumar Singh
This is very simple and easy: The sample code is as follows:
using System; using System.IO; //Namespaces needs for file Input/Output Operation namespace FILEIO { public partial class Form1 : Form { private void button1_Click(object sender, EventArgs e) { StreamWriter iSW = new StreamWriter(@"C:\Target.txt" ); // Open the target text file to write iSW.Write(textBox1.Text); // write the text to the file iSW.Close(); // close the stream writer } } }
There are two Magic Tables in SQL Server: 1. INSERTED:- This table is created when a trigger is created on a table for Insert and Update. 1. DELETED:- This table is created when a trigger is created on a table for Update and Delete. More important .NET Questions & Answer
The INSERTED and DELETED tables are called Magic tables which are maintained by sql server. When a table is updated, the affected row is inserted in the DELETED table and the new row is inserted in the INSERTED table before the updation process. When a row is inserted in a table the INSERTED table is populated and when a row is deleted from a table the DELETED table is populated.