How to count the rows?

  • Hi Friends,

    I use a cursor for updating some records and that update statement is a dynamic statement that i pass some values through variables. When the cursor completes the execution , it shows how many rows are affected in the progress bar. i need to get each individual count and add it and need to show how many rows are totally affected..

    i mean to say, it displays like

    5000 rows affected

    1586 rows affected

    153 rows affected

    i need to add all these rows and to get the total count ....is that possible?

    Thanks,
    Charmer

  • declare a variable and set it to the variable + @@rowcount on each itteration

    declare @rc bigint = 0

    set @rc = @rc + @@rowcount

  • anthony.green (5/28/2012)


    declare a variable and set it to the variable + @@rowcount on each itteration

    declare @rc bigint = 0

    set @rc = @rc + @@rowcount

    It really did worked...Thank you anthony...

    Thanks,
    Charmer

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply