Connecting Tech Pros Worldwide Forums | Help | Site Map

@@rowcount

Member
 
Join Date: Mar 2008
Location: Faridabad
Posts: 40
#1: Apr 24 '08
What is @@rowcount and with small code snippet explain the usage?

Member
 
Join Date: Dec 2007
Posts: 81
#2: Apr 25 '08

re: @@rowcount


Quote:

Originally Posted by Yogesh Sharma

What is @@rowcount and with small code snippet explain the usage?

If you just search for it out first you will be able to find the answer. I recommend google.com.

@@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
Expand|Select|Wrap|Line Numbers
  1. select * from myTable '@@rowcount = 3
  2. select * from myTable where ID = 3 '@@rowcount = 1
  3. update myTable set Name = 'Banana' where ID in (1,2) '@@rowcount = 2
  4. set @variable = 'Hello' '@@rowcount = 1
To learn more, click this .
ganeshkumar08's Avatar
Newbie
 
Join Date: Jan 2008
Posts: 31
#3: Apr 25 '08

re: @@rowcount


@@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.

Ganesh
Member
 
Join Date: Mar 2008
Location: Faridabad
Posts: 40
#4: Apr 25 '08

re: @@rowcount


Thx both of U frnds..........I Got it.
Reply