Try … Catch in SQL

The best practice to run SQL queries is to run them in transaction and wrap with SQL’s Try … Catch statement, so we could rollback the transaction, and throw an exception. Below is the code snippet that would do it all.