MAGIC TABLES IN SQL SERVER 2005

There are two magic tables named inserted and deleted.These tables are created in a trigger only.
You cannot create or use them outside the scope of the trigger.
You can use these table inside the trigger for your purpose like commit
or rollback of the transaction.SQL Server system creates these tables.

1. Insertion : whenever an insert takes place, the data goes into inserted table before the commit of the transaction.

2. Deletion : Whenever a row gets deleted from a table, data goes into deleted table.

3. Update : Since an update statement is a combination of delete and
insert so in case of update data goes in both, inserted and deleted
tables.

I will write one post of detailed example to make this more clearer.

Pawan Kumar
Pawankkmr@hotmail.com

Advertisements