Database Reference
In-Depth Information
The result should appear as in Figure 8-7.
Figure 8-7. Second operation failed, first operation rolled back
In the Messages pane shown in Figure 8-7, note that the transaction was rolled back because the
DELETE failed and was terminated with error number 547 (the message for which appears at the top of the
window). The INSERT error number was 0, so it apparently executed successfully but was rolled back. (If
you check the table, you'll find ag is not a person.)
How It Works
Since ag doesn't exist, SQL Server inserts the row, so the first operation succeeds. When the second
statement in the transaction is executed, SQL Server prevents the deletion of customer Vidvr because it
has child records in the PersonDetails table, but since gmaxerr isn't 0 (it's 547, as you see in the Results
pane), the entire transaction is rolled back.
 
Search WWH ::




Custom Search