开发者

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜