C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Interview Question


Posted Date: 30 Jun 2008      Posted By: CRPRAJAN      Member Level: Gold     Points: 1   Responses: 5



Under which situation we will use Magic Tables?




Responses

Author: chandramohan    30 Jun 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 1

http://www.dotnetspider.com/qa/Question11643.aspx

http://blogs.crsw.com/mark/articles/253.aspx

http://courtesyindia.com/software/interview/asp.net/welcome.aspx

http://www.crsw.com/mark/Lists/Posts/Post.aspx?ID=12

http://faisalmb.com/kbinterviewaspnet.html

http://www.dotnetspider.com/qa/Question11643.aspx

http://blogs.crsw.com/mark/articles/253.aspx

http://courtesyindia.com/software/interview/asp.net/welcome.aspx

http://www.crsw.com/mark/Lists/Posts/Post.aspx?ID=12

http://faisalmb.com/kbinterviewaspnet.html



Author: www.DotNetVJ.com    30 Jun 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 6

Hi

There are 2 Magic Tables in SQL server Inserted and Deleted.
These are mantained by SQL server for Internal processing whenever an update, insert of delete occur on a table. However, we can refere these tables in a Trigger.
Whenever an update table statement is fired SQL server mantains the original row before updation in a deleted table and New (updated )row in a Inserted Table.

Same is the case when an insert is fired Only Inserted table is populated with inserted Row.
and when Delete table statement is fired Deleted table is populated with the deleted row.

Check out the below link for more information
http://www.sql-server-performance.com/nn_triggers.asp

Thanks -- Vj
http://dotnetvj.blogspot.com

Thanks -- Vijaya Kadiyala
http://www.DotNetVJ.com
Microsoft MVP
Me & My Little Techie



Author: Bunty    30 Jun 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 6

Hi,

Magic Tables:
Whenever a trigger fires in response to the INSERT,DELETE,or UPDATE statement,two special tables are created.These are the inserted and the deleted tables.They are also referred to as the magic tables.These are the conceptual tables and are similar in structure to the table on which trigger is defined(the trigger table).
The inserted table contains a copy of all records that are inserted in the trigger table.
The deleted table contains all records that have been deleted from deleted from the trigger table.Whenever any updation takes place,the trigger uses both the inserted and deleted tables.

Thanks and Regards
S.S.Bajoria


Thanks & Regards
S.S.Bajoria



Author: Sandesh S    01 Jul 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 0

In creating triggers we use the magic tables


Author: Ratheesh    01 Jul 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 1

While using triggers these Inserted & Deleted tables
(called as magic tables) will be created automatically.

When we insert any record then that record will be added
into this Inserted table initially, similarly while
updating a record a new entry will be inserted into
Inserted table & old value will be inserted into Deleted
table.

In the case of deletion of a record then it will insert
that record in the Deleted table



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : how to find freespace,totalspace,usedspace in database
Previous : data migration-urgent
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use