You are here: Re: Create Delete Trigger on Table1 to Update a filed on Table2 « MsSQL Server « IT news, forums, messages
Re: Create Delete Trigger on Table1 to Update a filed on Table2

Posted by Erland Sommarskog on 01/12/08 14:53

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/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация