What are the magic tables in SQL Server 2000?
Answers were Sorted based on User's Feedback
Answer / kirti kumar agarwal
The INSERTED and DELETED tables, popularly known as MAGIC
TABLES, and update () and columns_updated() functions can
be used to determine the changes being caused by the DML
statements.
Note that the Magic Table does not contain the information
about the columns of the data-type text, ntext, or image.
Attempting to access these columns will cause an error.
| Is This Answer Correct ? | 44 Yes | 3 No |
Answer / maya
While using triggers these Inserted & Deleted tables
(called as magic tables) will be created automatically.
When we insert any record then that record will be added
into this Inserted table initially, similarly while
updating a record a new entry will be inserted into
Inserted table & old value will be inserted into Deleted
table.
In the case of deletion of a record then it will insert
that record in the Deleted table
| Is This Answer Correct ? | 40 Yes | 5 No |
Answer / jerry joseph
NO THERE IS NO UPDATED MAGIC TABLE
only 2 magic tables
- INSERTED
- DELETED
in case of an Update operation the original row is stored in
the DELETED table and the new row is saved in the INSERTED table
| Is This Answer Correct ? | 31 Yes | 0 No |
Answer / 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 |
Answer / ajay sadyal
Hi Friends
Magic table are created when we execute the DML statement
like insert,update and delete on database..
But these magic table are not accessible directly.You can
access these table only with triggers.
Becuase these table are only in the scope of triggers.
e.g deleted and inserted are two magic table..
CREATE TRIGGER [dbo].[EMPLOYEE_trgU]
ON [dbo].[EMPLOYEE]
FOR UPDATE AS
BEGIN
declare @name varchar(40)
SELECT @name = name from deleted WTIH (NOLOCK)
-- WITH (NOLOCK) enforce the sql-server not to Lock -
-- the data if there is any transaction implemented.
-- Now Update it with another table
UPDATE tbl_employee_log
SET description = @name + ' record has been deleted
from database'
END
Hope this will help.
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / kuber
is there any new table named "update magic table"???
| Is This Answer Correct ? | 6 Yes | 23 No |
Answer / vijayabhaskarreddy
wen we are performing DML operations into table . amagic
table created in the memory.
inserted magic table
deleted magic table
update magic table
| Is This Answer Correct ? | 3 Yes | 21 No |
what is macro?
5 Answers Excel, Global Innovation, Wipro,
Difference Between ORDER BY Clause and GROUP BY Clause in SQL?
Security Question- SQL DBA exparts, need your help...
In my application I have a process which picks the scanned files (tif format) from a shared location and it links to application and shown on it.The actuall issue is that my process picks the file before it is completly written or scanned which results in displaying few parts of the image or incomplete image.I need to check if the file is not completly scanned or written then do not link it to application.Please help if any body tell me that how can i check that file is in written phase or locked through DTS.thanking you in advance
what is a schema in sql server 2005? : Sql server database administration
What is the difference between a "where" clause and a "having" clause?
define and explain the differences between clustered and non-clustered indexes.
What is sql injection? How to protect against sql injection attack?
How to delete the duplicate rows from a table in SQL Server ??
What is measure group, measure? : sql server analysis services, ssas
how to copy only distinct data into another table which is not already exist in database?
What is named calculation? : sql server analysis services, ssas
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)