Re: Record level security?



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
.



Relevant Pages

  • Re: Add a datestamp to an existing table
    ... Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books ... ... Are there examples of creating a trigger for tracking table data ... If you choose a design with a seperate history table that holds all ...
    (comp.databases.ms-sqlserver)
  • Re: Record level security?
    ... and then another one that lists ... I would probably do it in one trigger, but I grow up in a cruel world ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: History/audit without history tables
    ... I would typically do this in a trigger. ... JOIN pledgegroupmembership pgm ON i.accno = pgm.accno ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Auditing and IP addresses
    ... Create a certificate and which you sign the trigger with. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: Record level security?
    ... Is "deleted d" referring to the table that the trigger is being created ... on?...or is it necessary syntax as is? ... Look it up in Books Online if it does not work. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (microsoft.public.sqlserver.security)