How can I get the number of rows affected by an UPDATE query in a Stored Procedure (SQL Server 2005), as a resultset. e.g.
CREATE PROCEDURE UpdateTables
AS
B
You might need to collect the stats as you go, but @@ROWCOUNT captures this:
declare @Fish table (
Name varchar(32)
)
insert into @Fish values ('Cod')
insert into @Fish values ('Salmon')
insert into @Fish values ('Butterfish')
update @Fish set Name = 'LurpackFish' where Name = 'Butterfish'
select @@ROWCOUNT --gives 1
update @Fish set Name = 'Dinner'
select @@ROWCOUNT -- gives 3