How can we know how many rows are deleted from table

  • Hi all

    How can we know how many rows are deleted from table?

    (for example we use delete from tablename, in this case i want to

    know how many rows deleted from table, is this possible or not?)

  • Use @@RowCount

    @@RowCount returns the number of rows affected by the last statement.

    Extract from SQL Server Books Online

    This example executes UPDATE and uses @@ROWCOUNT to detect if any rows were changed.

    UPDATE authors SET au_lname = 'Jones'WHERE au_id = '999-888-7777'IF @@ROWCOUNT = 0   print 'Warning: No rows were updated'
     

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

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