No matter how hard we try to design and develop applications, errors will always occur. There are two general categories – syntax or logical errors can be either programmatic errors or consequences of incorrect database design. Otherwise, you might get an error because of the wrong user input.

This is image title

T-SQL (the SQL Server programming language) allows handling both error types. You can debug the application and decide what you need to do to avoid bugs in the future.

Most applications require that you log errors, implement user-friendly error-reporting, and, when possible, handle errors and continue application execution.

Users handle errors on a statement level. It means when you run a batch of SQL commands, and the problem happens in the last statement, everything preceding that problem will get committed to the database as implicit transactions. This might not be what you desire.

Relational databases are optimized for batch statement execution. Thus, you need to execute a batch of statements as one unit and fail all of the statements if one statement fails. You can accomplish this by using transactions. This article will focus on both error handling and transactions, as these topics are strongly connected.

#database #sql #t-sql #sql-server #developer

Understanding the SQL Server Database Errors
2.40 GEEK