What would the following statement output in Query...

  • Comments posted to this topic are about the item What would the following statement output in Query...

  • I know it's very old question but i think explanation here is wrong. Output is 0 not because there's no rows updated but because @@rowcount holds number of rows affected by the last operation. Rollback (or commit) reset @@rowcount to 0.

    ptr

  • Piotr Ryszkowski (7/16/2009)


    I know it's very old question but i think explanation here is wrong. Output is 0 not because there's no rows updated but because @@rowcount holds number of rows affected by the last operation. Rollback (or commit) reset @@rowcount to 0.

    ptr

    You are right Piotr.

    BOL says: Statements such as USE, SET <option>, DEALLOCATE CURSOR, CLOSE CURSOR, BEGIN TRANSACTION or COMMIT TRANSACTION reset the ROWCOUNT value to 0.

  • good question...was aware of the functionality of row_count with roll back...

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

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

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