The SQL MERGE statement has been around since 2008 (10 years ) and is a great help for set based operations when inserting/updating rows. Updating your triggers to not block it would greatly be appreciated!
What is SQL Merge?
SQL Merge is a command that allows a programmer to do multiple inserts AND deletes in one command, instead of using separate commands for inserts and deletes.
How does using [select @numrows = @@rowcount] in VP's triggers block SQL MERGE?
Because SQL MERGE can do inserts, updates, and deletes all at the same time, the @@rowcount variable contains the TOTAL number of rows affected. Imagine for a moment that we are inserting 3 records, deleting 2, and updating 1. That's a total of 6 records affected. Thus, @@rowcount will be equal to 6. Let's step through the process as it hits a simple UPDATE trigger.
What about a INSERT trigger?
What WOULD happen if Viewpoint fixes their triggers:
What would it take for Viewpoint to fix their triggers?
Go through ALL their table triggers and replace [select @numrows = @@rowcount] with
Why go to all this work?
So that we can start using MERGE startements in our stored procedures. This is particularly useful when importing large amounts of data and can seriously speed things up. Using SET BASED OPERATIONS is always recommended over LOOPS whenever possible, by pretty much every SQL performance guru I've run across.
Viewpoint? What are your long term plans with the database?
Company | Cutting Edge Plumbing & Mechanical |
Job Title / Role | IT Admin |
I need it... | 1 month |
Dear Viewpoint Suggestion Box contributor;
We at Viewpoint sincerely thank you for your contribution to Suggestion Box on how we can improve Viewpoint products. While we can’t do everything at once, we rely upon your feedback to help guide the prioritization of our product improvements, and Suggestion Box is a critical tool for us to understand and prioritize our customers’ needs.
Viewpoint reviews Suggestion Box regularly for all of our products and updates statuses, adds comments, and performs various house-keeping (including deleting) as needed to ensure that Suggestion Box is maintained as a productive environment for product enhancements requests.
© 2023 Trimble Inc. All Rights Reserved. Viewpoint®, Vista™, Spectrum®, ProContractor™, Jobpac Connect™, Viewpoint Team™, Viewpoint Analytics™, Viewpoint Field View™, Viewpoint Estimating™, Viewpoint For Projects™, Viewpoint HR Management™, Viewpoint Field Management™, Viewpoint Financial Controls™, Vista Field Service™, Spectrum Service Tech™, ViewpointOne™, ProjectSight® and Trimble Construction One™ are trademarks or registered trademarks of Trimble Inc. or its affiliates in the United States and other countries. Other names and brands may be claimed as the property of others.
I need this perticularly on Table dbo.vDDUI Trigger vtDDUIi. It is only a one line change.
we want to use a merge statement to override the GridCol field from UserSrc to UserDest.
this way we can set create a standard column order accross all of our users.
Andre, do you have an updated list of those bugs? The pages linked say "Microsoft Connect has been retired" when trying to view the actual bug.
Thanks for the warnings about MERGE.
Perhaps we should be campaigning for VP to swap out their cursors for actual set-based operations?
https://www.datavail.com/blog/curse-of-the-cursors-in-code-development/
I'll keep this one on my wishlist though, as I'd love to see VP give a little more attention to their DB performance.
Merge statements have their downfalls.
I do agree if it's possible, but it's also important to keep this in mind. May be possible once minimum requirements change to SQL 2016.
https://www.mssqltips.com/sqlservertip/3074/use-caution-with-sql-servers-merge-statement/