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
Why I can not enter 0.001 second in date and time literals in ms sql server?
Explain the use of containers in ssis and also their types?
What is function of CUBE ?
What is the difference between indexing and hashing?
What are the features of Embedded SQL
What are the new features of sql server 2012 reporting service?
What is the difference between ddl and dml?
Describe in brief databases and sql server databases architecture.
What is user defined stored procedures?
Write a SQL query to make a column as unique?
How do I know if localdb is running?
What is difference between after and before?
How much space does sql server 2016 take?
What are sub reports and how to create them?
Explain different types of self contained sub query?