Number Of Rows Affected - @@ROWCOUNT

Akiii
Posted by Akiii under Sql Server category on | Points: 40 | Views : 1252
@@ROWCOUNT returns the number of rows affected by the last statement. For example :-

UPDATE table_name 
SET first_name = 'Dotnetfunda'
WHERE id = 1
IF @@ROWCOUNT = 0
print 'No rows were updated';


In the above example, table is updated where id = 1 . If there is no row affected then it will print a message.



Thanks and Regards
Akiii

Comments or Responses

Login to post response