I'm trying to find out whether a delete query executed properly. I know how many rows its supposed to delete, and I'd like to check that the number that were deleted, matches what's expected, from within the query itself.
How do I find out the number of rows that I just deleted, from within a SQL query running against MySQL? Separate statements are fine, as long as I can bundle them into one query.
You can use ROW_COUNT() function to check the number of deleted rows. The conditions in the WHERE clause (optional) identify which rows to delete. Without WHERE clause, all rows are deleted. If you specify the ORDER BY clause, the rows are deleted in specified order.
In SQL Server, you can use T-SQL's COUNT() function to return the number of rows that would be returned in a query.
Step 1: Use the beneath referenced command to check the number of rows present in the table from which the data got erased. Step 3: Collect all the data about the erased records from the SQL Server table to recover data. By using this command, you will acquire a Transaction ID of deleted records.
see MySQL ROW_COUNT function here http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_row-count
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With