What are the magic tables in SQL Server 2000?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we insert data into view sql server?

716


Why should one not prefix user stored procedures with ‘sp_’?

805


Hi, I Created 3 Tables Person(PersID[prkey],Name,Email,Password), Project(ProjName,ProjID[prkey],ProjLeader,ProjManager) & ProjectInvolvement(EntryDate,ProjID[frkey],PersID[frkey],ProjDuration). For this how can i INSERT,UPDATE & DELETE Through PROCEDURE? Please Post the Answer for me. Desai.

1617


What is change data capture (cdc) feature?

786


What is the process of normalising?

752






What are different types of raid levels?

745


What is the sql case statement used for? Explain with an example?

713


what are triggers? : Sql server database administration

659


Are there any preferred steps that need to be taken care of before starting the installation of sql server 2000?

743


Explain linked server in sql?

866


Explain different types of index?

769


What are rest-style architecture's?

163


Explain about local stored procedure?

700


What is the difference between index seek vs. Index scan?

771


Define left outer join in sql server joins?

710