开发者

SQL Server Number of records affected by an update before executing the actual update

开发者 https://www.devze.com 2023-01-10 17:47 出处:网络
Is there a way to get the number of records by an update-statement开发者_StackOverflow社区 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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号