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
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
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