August 28, 2024 at 12:42 pm
I have a sql query that runs on demand to generate a report. I want to update a field REPORTSENT to a Y on the selected results.
So the next time the report is requested only the Records with a REPORTSENT = N will be returned. Normally would run the query for the records and then an update with the same where clause to mark the REPORTSENT = Y. I was hoping that there would be a way to do it in one process.
August 28, 2024 at 1:31 pm
Do it in the other order. Use UPDATE to update the records using the OUTPUT clause to output your required fields.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 28, 2024 at 2:17 pm
Drew's suggestion is the way forward. Here is an article which demonstrates the technique:
https://www.sqlservercentral.com/articles/the-output-clause-for-update-statements
August 28, 2024 at 2:31 pm
Thank you for pointing me to a solution.
September 3, 2024 at 6:39 am
This was removed by the editor as SPAM
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy