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
can any body tell me how to know the password of current user in sql server
Difference between connected and disconnected database in .net with sql server?
What is a partitioned view?
Explain “@@rowcount” and “@@error” in sql server?
How to optimize stored procedure optimization?
How to convert character strings into numeric values?
What do you understand by integration services in sql server?
What is the rdl file?
What is mapping schema?
What is it unwise to create wide clustered index keys?
What is the difference RDBMS and Graph Database?
What is difference between aggregate and analytic function?
Explain about sql server login?
What is the purpose of the model database?
what are the different types of replication you can set up in sql server? : Sql server database administration