@@rowcount

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yogesh Sharma
    New Member
    • Mar 2008
    • 40

    @@rowcount

    What is @@rowcount and with small code snippet explain the usage?
  • deric
    New Member
    • Dec 2007
    • 92

    #2
    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
    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
    To learn more, click this .

    Comment

    • ganeshkumar08
      New Member
      • Jan 2008
      • 31

      #3
      @@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

      Comment

      • Yogesh Sharma
        New Member
        • Mar 2008
        • 40

        #4
        Thx both of U frnds.......... I Got it.

        Comment

        Working...