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?

What is error handling? - SQL Server Tutorial

From the course: Program Databases with Transact-SQL

Start my 1-month free trial

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…

Contents