Groups | Blog | Home
all groups > sql server clients > march 2006 >

sql server clients : Capture Result of Update?


bradwiseathome NO[at]SPAM hotmail.com
3/30/2006 12:27:44 PM
I have an Update statement in a stored procedure, and I want to capture
the number of rows affected for returning to the caller. If this was a
simple Insert, I'd use Scope_Identity() to get the Identity. But in
this case I want the count of all updated rows.

Thanks.
Tom Cooper
3/30/2006 4:28:15 PM
You want to use either @@RowCount (or RowCount_Big() if there is any
possibility that more than 2 billion rows may be affected by the Update
statement.

Something like:

Declare @UpdateCount int
Update Mytable Set ... Where ...
Select @UpdateCount = @@RowCount

Tom

Then @UpdateCount will contain the number of rows which matched the Where
clause in your Update statement.
[quoted text, click to view]

AddThis Social Bookmark Button