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 the four main query statements?

7 Answers   Wipro,


what is Constraint? How many types of constraints in SQL ?

38 Answers   HCL, IBM, NIIT, Wipro,


What is the difference between writing data to mirrored drives versus raid5 drives

0 Answers  


How to Get the last identity value used

4 Answers  


What is indexed views? plz explain with example?

2 Answers  






How retrieve field names from the table in SQL through JAVA code?

0 Answers  


How do you test your database? : sql server database administration

0 Answers  


how would you troubleshoot blocking? : Sql server database administration

0 Answers  


How to insert data with null values?

0 Answers  


write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 shanker Honda 3 shanker car 4 Balu pulsar 5 Balu Honda 6 Balu car 7 Shyam pulsar 8 Jaya Honda 9 Deepa car 10 vasu car

12 Answers   Cognizant, TCS,


What is the return type of executeupdate ()?

0 Answers  


What is INTVAL( )and where we use Plz any body help me

1 Answers  


Categories