What is @@rowcount and with small code snippet explain the usage?
@@rowcount
Collapse
X
-
Tags: None
-
Originally posted by Yogesh SharmaWhat is @@rowcount and with small code snippet explain the usage?
@@RowCount returns the number of rows affected by the last statement.
Anyway, here are some simple snippets that could explain @@rowcount:
For example, if you have these records on a myTable:
ID - Name
-----------------------
1 - Apple
2 - Orange
3 - Grapes
Code:select * from myTable '@@rowcount = 3 select * from myTable where ID = 3 '@@rowcount = 1 update myTable set Name = 'Banana' where ID in (1,2) '@@rowcount = 2 set @variable = 'Hello' '@@rowcount = 1
-
@@Rowcount - Returns the number of rows affected by the last statement.
For Example.
If Table1 Has 20 rows in the DB.
If we execute the query as below
select * from Table1
Print @@Rowcount
Now the above stmt returns 20 rows, so the count will be 20.
GaneshComment
-
Comment