Here is another popular lab from Hands-On-Lab library: Error Handling in SQL Server.
Error Handling is very essential in every programming language, similarly in SQL server we have multiple built in functions to handle errors that may occur in TSQL code. This lab is divided into six exercises explaining different types of Error Handling functions. In first exercise we will learn to detect errors using @@ERROR system variable. In second exercise we will understand structured error handling using TRY…CATCH blocks. In third exercise we will learn to raise user defined errors using @@RAISERROR system variable. In fourth exercise we will learn to throw errors using THROW function. Fifth exercise is Self-Assessment, where a problem is given and you to solve by yourself. Sixth exercise presents the TSQL challenge that needs to be solved (slightly tougher than self-assessment).
Exercise 1: Detect the errors using @@ERROR
Exercise 2: Understanding structured error handling using TRY… CATCH
Exercise 3: Raising user-defined errors using @@RAISERROR
Exercise 4: Throw an error using THROW exception
Exercise 5: Self-Assessment
Exercise 6: T-SQL Challenge
SQLMaestros Hands-On-Labs enables the practical way of learning. Each lab document consists of multiple exercises and each exercise consists of multiple tasks. Apart from step-by-step instructions, the HOL document contains images, explanations, observations, notes, tips & tricks to ensure a great learning experience. With each lab, you can practice a specific concept step-by-step. With our HOL documents, you will get hands-on with hundreds of topics in SQL Server & Microsoft Data Platform. Learn More.