If you have a @ symbol in the field AND
If there is a subquery with "GROUP BY" in it for a JOIN.
Your stored procedure dbo.vspVAWDTestQuery does not take the above condition into consideration. If it sees a @ symbol it then looks for "GROUP BY" and does some truncating, completely ignoring the idea that someone might have a GROUP BY within a subquery in a join, not just at the very bottom.
Why would it be useful to have a JOIN with a GROUP BY within it? It makes summarizing (or finding the last row of a thing) much easier. In my case, the last status update from a log.
I realize the goal of the TESTQUERY is to validate the SQL. With that in mind, are you aware of the following command?
sp_describe_first_result_set
(Link above is just a link to Microsoft's page on the command).
Instead of hunting around for WHERE based on if @ does or does not exist, how about:
Get all the variable names together
Pass them to the procedure above.
This would remove your need to do truncating or searching for the WHERE clause.
This way it does not matter if any code is commented out, and it leaves ALL the SQL parsing to the engine. The only code you'd have to think about is how to detect the @names to build to pass to the procedure.
Thanks.
Company | Cutting Edge Plumbing & Mechanical |
Job Title / Role | Lead Developer |
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.