views:

40

answers:

1

I need to find the amount of updated rows

UPDATE Table SET value=2 WHERE value2=1

declare @aaa int
set @aaa = @@ROWCOUNT

It doesn't work. How can I do that?

+2  A: 
  1. You may want to declare before you do the update. I am not sure but declare statement might affect @@rowcount.

  2. You are not getting the @aaa value back - you want to select it out if you want to see it outside the query

.

declare @aaa int -- this name's noty the best... use @row_count instead ;)
UPDATE Table SET value=2 WHERE value2=1
set @aaa = @@ROWCOUNT
select @aaa
DVK
Thanks! That works. I also found out that I can use CAST function.
Alex
@Alex - you're welcome. You might want to accept the answer if it was helpful - that's the big checkmark to the left of the answer :)
DVK
I always do :) The thing is it asked me to wait for 8 minutes, and I forgot to, sorry. Accepted now.
Alex