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 are the five characteristics of good data?
Explain what are the database objects? : SQL Server Architecture
How to find the service pack installed? : sql server database administration
How to use group functions in the select clause in ms sql server?
How to make a remote connection in a database?
How do I completely remove sql server instance?
Do you know what are the differences between lost updates and uncommitted dependencies?
Why do we use non clustered index?
What is ddl and dml commands?
How to select true false based on column value in sql server?
what types of replication are supported in sql server? : Sql server database administration
What is set nocount on?
How to get a list of table columns using the "sp_columns" stored procedure in ms sql server?
Explain different types of Normalization.
Can we add a cpu to sql server?