What are the magic tables available in SQL Server 2000?
By in SQL Server on Jul 20 2006
  • Bhawna Raghuvanshi
    Sep, 2014 17

    Sql server creates two temprory tables(Inserted and Deleted) when the INSERT, UPDATE, DELETE operation performed.These tables are called Magic tables.When Insert Operation performed, Inserted table also contain theses values.When Update Operation performed,the old values inserted in Deleted table and new values inserted in Inserted table.When Delete Operation performed, Deleted table contain these values.Magic table is used for Trigger handling.

    • 0
  • Sachin Kalia
    Jun, 2012 25

    in a simple words magic table are Inserted tables and deleted tables.Which is used in trigger handling.e.g if we've set a trigger on a table and when any of these actions(inserted,deleted,Updated) fire on any table @ moment trigger fires and gets the last updated value of triggered table modified by DML statements.NOTE;Inserted and Deleted has been introduced as keywords in SQLServer 2008

    • 0
  • vivek kumar pandey
    Jun, 2012 6

    Magic table is automatic generated table in mssql server . it is use in Trigger Handling

    • 0
  • Lajapathy Arun
    Apr, 2012 28

    Sql Server automatically creates and manages two temporary, memory-resident tables (deleted and inserted tables) which are popularly known as magic tables.

    • 0
  • Supratik De
    Jan, 2010 26

    Magic tables are used to put all the deleted and updated rows. We can retrieve the
    column values from the deleted rows using the keyword "deleted"

    To project the deleted data into the deleted table we will use "output" clause
    Below is the sample code to retrieve the deleted data.

     

    DECLARE @DeletedTable TABLE(DeletedTableID INT, DeletedData VARCHAR(20))

    Code Snippet:


    DELETE VENKATOutput
    OUTPUT Deleted.KeyID, Deleted.Name INTO @DeletedTable WHERE KeyID > 3
    SELECT * FROM @DeletedTable

     

    Similarly, we can retrieve the updated data and old data too using the keyword "Inserted"

    • 0
  • Jul, 2006 25

    Yes, this is the exact answer what has been given by Praveen.

    Thanks Praveen
    Manoj(InfoAxon Technologies Limited)

    • 0
  • pravs
    Jul, 2006 24

    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

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS