Possible Duplicate:
Getting no. of rows affected after running select query in SQL Server 2005
How can I get the number of rows updated by an update? Something like this:
select update container set a = 1
Possible Duplicate:
Getting no. of rows affected after running select query in SQL Server 2005
How can I get the number of rows updated by an update? Something like this:
select update container set a = 1
You can use
SET NOCOUNT OFF;
GO
this will show a count of the number of rows that were updated.
You can also use the ever-so-cool @@ROWCOUNT
variable which returns that number of rows affected by the last operation.
SELECT @@ROWCOUNT;
GO
I hope this helps.
DECLARE @UPDATED_RECORDS int
SET @UPDATED_RECORDS = 0
select update container set a = 1
Select @UPDATED_RECORDS = @@ROWCOUNT
Immediately following the update statement and you should get the total number of records updated now stored in the @UPDATED_RECORDS variable.
Of course, without a filter on the update, you are updating every row in the table, so in this case SELECT COUNT(1) FROM CONTAINER should provide the same result.