Regarding Triggersgreenspun.com : LUSENET : SQL Server Database Administration : One Thread
Hi, I have a problem.I have a trigger for update on a particular column. The trigger fires even though the update fails (i.e the condition is redundant). I want to avoid this. Is there a simple way around it rather than through programming.
Under what circumstances should I go in for a keyset cursor? Thank YOu
-- Anonymous, June 28, 1999
Your update trigger should check the value of @@ROWCOUNT and/or the contents (if any) of the "deleted" and "inserted" tables to determine if has any processing to do. (Sorry, this is programming.)
Regarding keyset cursors: immediately upon executing a recordset.Update method you can reference the value of the ID field because in a Keyset recordset the changes are visible immediately. Also, if you are going to use this value to insert into other tables because of a foreign key relationship, you could open a View instead of the separate tables and when the ID field is set, the foreign keys based on this key are also set without you having to do it explicitly.
I would use the keyset cursor when these features are valuable.
Hope this helps,
-- Anonymous, June 29, 1999