Reputation: 2685
I'm using sql2000 but I'm also using mysql, and sql2008 and am interested in how to count the number of updates I justed updated? I do see where there is an updated table but not sure if that's within a normal query. thx
declare @updateCount as int
set @updateCount = 0
begin transaction
set @updateCount = update GENIUSES set IQ=161 where IQ=86 and username like 'RetroCoder'
print @updateCount
if @updateCount = 1
commit
else
rollback
Upvotes: 2
Views: 131
Reputation:
Declare @count int
update GENIUSES set IQ=161 where IQ=86 and username like 'RetroCoder'
Set @count = @@Rowcount
select @count
Upvotes: 3
Reputation:
In SQL Server:
DECLARE @updateCount INT;
UPDATE dbo.GENIUSES set IQ=161 where IQ=86 and username like 'RetroCoder';
SELECT @updateCount = @@ROWCOUNT;
Upvotes: 4