From the course: Program Databases with Transact-SQL
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Add error handling to a stored procedure - SQL Server Tutorial
From the course: Program Databases with Transact-SQL
Challenge: Add error handling to a stored procedure
(upbeat electronic music) - [Instructor] 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
What is error handling?1m 52s
-
(Locked)
Capture errors with TRY and CATCH4m 54s
-
(Locked)
Generate errors with THROW4m 12s
-
(Locked)
Manage transaction control4m 4s
-
(Locked)
Challenge: Add error handling to a stored procedure1m 12s
-
(Locked)
Solution: Add error handling to a stored procedure12m 12s
-
(Locked)
-
-