View Single Post

   
  #6 (permalink)  
Old 03-01-2008, 03:47 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Create Delete Trigger on Table1 to Update a filed on Table2

SagiPhoenix@AlbionLab (zkvneml@gmail.com) writes:
> ad the condition of the deleted deleted record's identity ID to the
> update statement. the ID can be fetched using
>
> select @recKeyID = {identity column name} from deleted


No! No! No!

A trigger fires once per *statement* and there can be more than one
row in deleted/inserted.

And who says that the table has an IDENTITY column? If you have IDENTITY
columns in all your tables, you have a habit that you need to change.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Reply With Quote