SQLConfiguration SQLConfiguration


Transactions Locks «Prev  Next»

Handling Transaction Errors - Exercise

Objective: Practice handling errors in your transactions.

Exercise scoring

This exercise asks you to accurately handle errors, as described in the instructions.

Instructions

Add error handling to test for errors after the statement to insert data is executed. If there are any errors, rollback the transaction and return. Use these Transact-SQL statements to add error handling:

BEGIN TRAN
INSERT INTO Clients (CompanyName, AddressLine1, City, State, 
Zip, ContactLastName, ContactFirstName, ContactPhone)
VALUES ('Acme Limited', '400 Main Street', 'Chicago', 'IL',
'60609', 'Jones', 'John', '1234567890')
COMMIT TRAN

Submitting the exercise


Type or paste your statements into the text box below, then click Submit to submit them and view a results page.