What are the magic tables in SQL Server 2000?

Answers were Sorted based on User's Feedback



What are the magic tables in SQL Server 2000?..

Answer / kirti kumar agarwal

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.

Is This Answer Correct ?    44 Yes 3 No

What are the magic tables in SQL Server 2000?..

Answer / maya

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

Is This Answer Correct ?    40 Yes 5 No

What are the magic tables in SQL Server 2000?..

Answer / jerry joseph

NO THERE IS NO UPDATED MAGIC TABLE

only 2 magic tables

- INSERTED
- DELETED

in case of an Update operation the original row is stored in
the DELETED table and the new row is saved in the INSERTED table

Is This Answer Correct ?    31 Yes 0 No

What are the magic tables in SQL Server 2000?..

Answer / deepak rawat

The tables "INSERTED" and "DELETED" are called magic tables
of the
SQL Server. We can not see these tables in the data base.
But we can access these
tables from the "TRIGGER"

When we insert the record into the table, the magic
table "INSERTED" will be created
In that table the current inserted row will be available.
We can access this
record in the "TRIGGER".


When we delete the record from the table, the magic
table "DELETED" will be created
In that table the current deleted row will be available. We
can access this
record in the "TRIGGER".

Following code Explain the magic table "DELETED"

CREATE TRIGGER LogMessageON EMPFOR DELETEAS DECLARE
@EMPNAME varchar(50) SELECT @EMPNAME= (SELECT EMPNAME
FROM DELETED) INSERT INTO LOGTABLE(UserId,Message) values
(@EMPNAME,'Record Removed')GO


The magic tables "INSERTED" and "DELETED" are main concept
of the "TRIGGER".
By using these tables we can do lot of useful
functionalities. The above code is
used to update the "LOGTABLE"

Is This Answer Correct ?    12 Yes 2 No

What are the magic tables in SQL Server 2000?..

Answer / ajay sadyal

Hi Friends

Magic table are created when we execute the DML statement
like insert,update and delete on database..

But these magic table are not accessible directly.You can
access these table only with triggers.
Becuase these table are only in the scope of triggers.

e.g deleted and inserted are two magic table..

CREATE TRIGGER [dbo].[EMPLOYEE_trgU]
ON [dbo].[EMPLOYEE]
FOR UPDATE AS
BEGIN
declare @name varchar(40)

SELECT @name = name from deleted WTIH (NOLOCK)

-- WITH (NOLOCK) enforce the sql-server not to Lock -
-- the data if there is any transaction implemented.

-- Now Update it with another table

UPDATE tbl_employee_log
SET description = @name + ' record has been deleted
from database'


END

Hope this will help.

Is This Answer Correct ?    5 Yes 1 No

What are the magic tables in SQL Server 2000?..

Answer / kuber

is there any new table named "update magic table"???

Is This Answer Correct ?    6 Yes 23 No

What are the magic tables in SQL Server 2000?..

Answer / vijayabhaskarreddy

wen we are performing DML operations into table . amagic
table created in the memory.
inserted magic table
deleted magic table
update magic table

Is This Answer Correct ?    3 Yes 21 No

Post New Answer

More SQL Server Interview Questions

What are indexes in ms sql server?

0 Answers  


What are the types of stored procedures in an sql server?

0 Answers  


Explain few examples of stored procedure over triggers?

0 Answers   ADITI,


What is a ddl statement?

0 Answers  


Can I run multiple instances of sql server 2000 at the same time on one computer?

0 Answers  






what is a self join? : Sql server database administration

0 Answers  


Explain the categories of stored procedure?

0 Answers  


what is an extended stored procedure? : Sql server database administration

0 Answers  


Why do we use trigger?

0 Answers  


What are the different types of replication? How are they used?

3 Answers  


How self join is different from outer join?

0 Answers   Blue Star,


how to implement locking in sql server

3 Answers   Satyam,


Categories