declare @test as table (id int identity (1,1),Name varchar(50),salary money)
insert into @test values ('AAA',5000),('BBB',6000)
IF @@ROWCOUNT =0
BEGIN
PRINT 'Warning: No rows were updated';
END
ELSE
BEGIN
PRINT 'rows were updated';
END
update @test set Name='CCC' where id=3
IF @@ROWCOUNT =0
BEGIN
PRINT 'Warning: No rows were updated';
END
ELSE
BEGIN
PRINT 'rows were updated';
END
Output
(2 row(s) affected)
rows were updated
(0 row(s) affected)
Warning: No rows were updatedReturns the number of rows affected by the last statement. If you check the last transaction is success or fail at time use rowcount.
