[posted and mailed, please reply in news]
Eddy Fontaine (ed***********@advalvas.be) writes:
Could somebody post some simple example how one can refer to
a column in the 'deleted' temporary table within a trigger definition ?
Should the 'deleted' and 'inserted' temp tables be declared, or they are
'implied' ?
They are implied. You just use them.
I keep having this msg when trying to create a trigger
"The column prefix 'deleted' does not match with a table name or alias
name used in the query"
May I guess that you are using dynamic SQL? Code executed in EXEC() or
sp_executesql is not part of the trigger, but constitutes a scope on
its own.
A practical workaround is to say:
SELECT * INTO #deleted FROM deleted
SELECT * INTO #inserted FROM inserted
first in the trigger.
This can even be useful in a trigger that does not use dynamic SQL,
particular if multi-row operations are common, because you can get
better performance. The virtual tables inserted and deleted are
not very efficient when they get some size.
--
Erland Sommarskog, SQL Server MVP,
so****@algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp