Re: Record level security?
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Sat, 19 Jan 2008 02:44:30 -0800
zz12 (IDontLikeSpam@xxxxxxxxxxx) writes:
Is "deleted d" referring to the table that the trigger is being created
on?...or is it necessary syntax as is? I'm trying to slightly adjust
the code to work with our real table names and fields and I have the
RAISERROR error working on the insert and update action but seems like
the trigger is not sensing the delete action and it is allowing it to
delete a test record which is suppose to be frozen.
In a trigger, you have access to two virtual tables "inserted" and
"deleted". "inserted" holds the inserted rows for an INSERT statement,
and "deleted" holds the deleted rows for a DELETE statement. In the
case of an UPDATE statement, both table are populated, with "inserted"
holding the rows after the update, and "deleted" the rows as they were
before the UPDATE.
The "d" is just an alias. It's best practice to always use table aliases
as prefixes; using the table names as prefixes causes code clutter.
For more information on triggers, look up the CREATE TRIGGER statement
in Books Online.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- Re: Record level security?
- From: zz12
- Re: Record level security?
- References:
- Record level security?
- From: zz12
- Re: Record level security?
- From: Erland Sommarskog
- Re: Record level security?
- From: zz12
- Re: Record level security?
- From: Erland Sommarskog
- Re: Record level security?
- From: zz12
- Record level security?
- Prev by Date: Re: Record level security?
- Next by Date: Re: Urgent problem about SQL Server
- Previous by thread: Re: Record level security?
- Next by thread: Re: Record level security?
- Index(es):
Relevant Pages
|