From the course: Program Databases with Transact-SQL
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
What is error handling? - SQL Server Tutorial
From the course: Program Databases with Transact-SQL
What is error handling?
- [Instructor] In a perfect world all of our interactions with the database, every command or transaction would occur flawlessly, man, exactly as expected every time. But we know that that's not the case. And it's important to plan ahead for potential errors to disrupt the programs that we write. The process of building in graceful responses to these disruptions is called error handling. Whenever you write a program or send instructions, you're telling the computer to basically do some things. Error handling adds an extra step. Here, We'll add on an extra bit that says, "If an error occurs, do different things." So with error handling, we're rerouting or interrupting the execution of a routine and telling it to perform a different set of tasks instead. In a SQL Server Database, this could look like this, you instruct the server to insert a new row in a table. The error handling routine might say, "If that doesn't work for any reason, "wait five minutes and try again." When adding in…
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)
-
-