How to continue a SQL query when an error is detected?

How can you continue an SQL query if an error is detected during a query?

I want to continue the request if any error occurs. I want to get the output of a specific operator and want to find out if the last output of the request.

How can you do this in T-SQL?

+4
source share
1 answer

You can use TRY-CATCH to handle errors.

You can find enough documentation here: http://msdn.microsoft.com/en-us/library/ms175976.aspx

UPDATE:

After a bit more research, I found that using the GO command will allow you to continue with the next request, and you won’t have to rebuild all the code using TRY-CATCH instructions. I still recommend using TRY-CATCH instructions for error management, but just use GO between.

This is the link where I found the answer: continue-executing-sql-statements-despite-errors

+8
source

Source: https://habr.com/ru/post/1487249/


All Articles