我正在使用sql2000,但我也使用mysql和sql2008并且对如何计算我更新的更新数量感兴趣?我确实看到有更新表的位置,但不确定是否在正常查询中。 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
答案 0 :(得分:4)
在SQL Server中:
DECLARE @updateCount INT;
UPDATE dbo.GENIUSES set IQ=161 where IQ=86 and username like 'RetroCoder';
SELECT @updateCount = @@ROWCOUNT;
答案 1 :(得分:3)
Declare @count int
update GENIUSES set IQ=161 where IQ=86 and username like 'RetroCoder'
Set @count = @@Rowcount
select @count