From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Challenge: Add error handling to a stored procedure

Challenge: Add error handling to a stored procedure - SQL Server Tutorial

From the course: Complete Guide to Advanced SQL Server

Challenge: Add error handling to a stored procedure

For the last challenge of this course, I'd like you to return to the stored procedure that was developed at the end of the previous chapter. If you remember, we created a procedure that contained a transaction that would help transfer money from one bank account to another. Now, it's time to add some error handling to the procedure. You can either continue developing your own procedure or use the 05_06_Challenge-Start.sql file to pick up with a solution that I came up with. The goal of the challenge is to gracefully handle three different situations. First, make sure that the account that the money is coming from won't fall below a zero balance. We don't want to allow anyone to overdraft their account. Second, make sure that the money is coming from an account that actually exists. And third, it's probably a good idea that the account the money is going into also exists. Only complete the transfer once all three of these conditions are met. I estimate that this challenge should take…

Contents