Katmai : Merge does not distinguish rowcounts in triggers - by AaronBertrand

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


14
0
Sign in
to vote
ID 298395 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 9/17/2007 7:58:18 AM
Access Restriction Public

Description

Many people rely on checking @@ROWCOUNT in triggers to determine whether to perform certain operations.  When a MERGE statement fires, it passes the sum of rows affected in any INSERT, UPDATE or DELETE operations, instead of the individiual rowcounts for each operation.  This occurs in both a combined trigger (for INSERT, UPDATE, DELETE) and individual triggers that capture each type of operation.
--
I realize that people should move away from @@ROWCOUNT for this type of control of flow, however there is a lot of code out there right now that is going to break, and unless this behavior is properly documented, it will be without warning.
Sign in to post a comment.
Posted by Jamie Thomson on 2/7/2013 at 6:46 AM
Closed as won't fix with no explanation. <sigh>
Posted by Naomi N on 2/12/2012 at 7:45 AM
This will be very helpful.
Posted by Jamie Thomson on 8/28/2009 at 6:31 AM
"For a future release of SQL Server, we'll look into providing a mechanism to easily retrieve the row count specific to each DML action in a MERGE statement."

That gets my vote!!!
Posted by Microsoft on 1/31/2008 at 6:41 PM
Hello

Thanks for the feedback. By design, when used with MERGE, @@ROWCOUNT returns the total number of rows inserted, updated, and deleted. This is currently documented in the "MERGE (Transact-SQL)" topic in SQL Server 2008 Books Online [http://msdn2.microsoft.com/en-us/library/bb510625(SQL.100).aspx]. In order to clarify this further, we are working on calling out this specific behavior, i.e. @@rowcount in triggers, in the documentation.

For a future release of SQL Server, we'll look into providing a mechanism to easily retrieve the row count specific to each DML action in a MERGE statement.

Thank you.


-- SQL Server Engine Team