SQL Server Number of records affected by an update before executing the actual update
Is there a way to get the number of records by an update-statement开发者_StackOverflow社区 before executing the actual update?
I know you can just create a select count(1) statement, but my process needs something more generic.
Do you mean something like this? So you can use the Count in the Update statement itself?
WITH p
AS
(
SELECT *,
COUNT(*) OVER() AS C
FROM tbl
WHERE id IN (1,7,8,9)
)
UPDATE P SET Col = C
精彩评论