What are the magic tables available in SQL Server 2000?
Select an image from your device to upload
Magic tables are used to put all the deleted and updated rows. We can retrieve thecolumn values from the deleted rows using the keyword "deleted"To project the deleted data into the deleted table we will use "output" clauseBelow is the sample code to retrieve the deleted data.
DECLARE @DeletedTable TABLE(DeletedTableID INT, DeletedData VARCHAR(20))
Code Snippet:
DELETE VENKATOutputOUTPUT Deleted.KeyID, Deleted.Name INTO @DeletedTable WHERE KeyID > 3SELECT * FROM @DeletedTable
Similarly, we can retrieve the updated data and old data too using the keyword "Inserted"
The INSERTED and DELETED tables, popularly known as MAGIC TABLES, and update () and columns_updated() functions can be used to determine the changes being caused by the DML statements.Note that the Magic Table does not contain the information about the columns of the data-type text, ntext, or image. Attempting to access these columns will cause an error.
This answer was posted at dotnetspider
Reference URL:
http://www.dotnetspider.com/kb/Article1733.aspx