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
What is dbcc command in sql server?
What are the different type of replication in sql server?
What are views used for?
What is the data tier application?
how can you select rexcord(rows) from table A which is not present in Table B . Id being the FK in Table B referencing to ID Table A
What is normalization of database? What are its benefits?
Explain database normalization?
Explain partitioned view?
Why are views required in the sql server or in any other database?
How do we Backup SQL Azure Data?
What are pages and extents? : SQL Server Architecture
Why we should not use triggers?
Name and describe few console utilities for ssrs?
What is trigger and different types of Triggers?
What is a join in sql? What are the types of joins?