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
How to trouble shoot if unable to connect SQL Server
What do mean by xml datatype?
mention different types of relationships in the dbms?
what is the difference between them (ethernet networks and token ring networks)? : Sql server database administration
What is the difference between DataRow.Delete() and DataRow.Remove()?
How to count groups returned with the group by clause in ms sql server?
Why SQL Agent is used?
How many types of dimensions are there and what are they? : sql server analysis services, ssas
Differentiate between SQL and ORACLE joins and write their syntax.
How you trouble shoot when any job fails
How do you make a trace?
What are the limitations/drawbacks or ssrs 2008 r2?
List the different normalization forms?
How many tables can be joined in SQL Server?
How each E-R model constructs can be mapped to the relational model?