How can you continue SQL query when found error while querying?
I want to continue a query if any error will occur. I want to get the output of a certain statement and want to see if what is the last output of the query.
How can you do it in T-SQL?
You can use a TRY-CATCH for error handling.
You can find enough documentation here : http://msdn.microsoft.com/en-us/library/ms175976.aspx
UPDATE:
After a bit more research I have found that using a GO command will allow you to continue to your next query, and you won't have to restructure your entire code with TRY-CATCH statements. I still recommend using TRY-CATCH statements to control errors, but just use GO between them.
This is the link where I found the answer: continue-executing-sql-statements-despite-errors
TRY...CATCH.
1,2from the followingSELECT * FROM (SELECT 1 UNION ALL SELECT CAST('X' AS INT) UNION ALL SELECT 2) T(C)