Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MERGE Syntax
Message
From
19/01/2017 07:11:15
 
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2012
Miscellaneous
Thread ID:
01646827
Message ID:
01646842
Views:
41
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform