Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MERGE Syntax
Message
De
19/01/2017 07:11:15
 
 
À
18/01/2017 19:29:14
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2012
Divers
Thread ID:
01646827
Message ID:
01646842
Vues:
42
>If I can make a suggestion - you might want to considering adding this, in addition to the JOIN between Inserted and Deleted
>
>
>WHERE D.iQty <> i.IQty
>
>
>(and you might even need to account for NULL values as well)
>
>Reason for this - if the trigger fires even though a quantity wasn't changed (i.e. old value and new value are the same), the MERGE doesn't need to occur.
>
>Also -just curious, why use a MERGE when you're only performing an UPDATE?


Thanks for the suggestions.

To be honest, the merge was new to me when I implemented it (and I have not used it since) so I am unsure as to the reason for it being used.

I have similar triggers for insert and delete. (Yikes, looking at it, the Update is done for AFTER INSERT and the Insert is for AFTER INSERT too!)

What would be the better/alternative way to do this?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform