sql - TSQL SELECT then UPDATE in one transaction, then return SELECT - Stack Overflow

sql - TSQL SELECT then UPDATE in one transaction, then return SELECT - Stack Overflow

瀏覽:848
日期:2025-11-20
Use a common table expression to select the data, then update the CTE and output from the UPDATE statement. This way everything is one single operation: with cte as ( SELECT TOP 20 item_id, field2, field3 FROM Table1 WITH (ROWLOCK, UPDLOCK ......看更多