The following SQL contains a subtle bug that will always result in the text “No Rows Affected” being output. The error occurs because the reference to @@ERROR in the first “IF” statement counts as a SQL statement; resetting the value held in @@ROWCOUNT. As the second “IF” statement checking @@ROWCOUNT is only evaluated if the first “IF” statement (@@ERROR) it will always return true! Note: Reversing the order of the two IF statements would hide . . .
November 18, 2010