I am trying to test result when ARITHABORT and ANSI_WARINGS are ON in Compatibility level 80 and Compatibility level 140. I use TRY - CATCH to catch domain errors too. The result is different in two level. In compatibility level 80, error conditions cause the query to end and CATCH clause is not executed. In compatibility level 140, error conditions cause the query to end and CATCH clause is executed.

Can you explain why have different in two compatibility level?

This is my code:


    PRINT N'OSQL Success'
    PRINT N'OSQL Failure'
  • 2
    80 is SQL Server 2000. There was no TRY/CATCH back then. In fact, I'm surprised you don't get a syntax error immediatelly – Panagiotis Kanavos Sep 20 '19 at 8:30
  • 1
    What's the point of using compatibility level 80? SQL Server 2000 is very old and many of the features used nowadays didn't exist back then. The database engine is completely different which means that setting the compatibility level to 80 won't make a database work as if it was a SQL Server 2000 instance – Panagiotis Kanavos Sep 20 '19 at 8:32
  • I think SQL Server 2008 was the last one to even offer compatibility level 80, and even it is out of support now. – Damien_The_Unbeliever Sep 20 '19 at 8:34
  • The fact that you are using Compatibility 80 and 140 (2000 and 2017) means you're using 2 different instances as well. The newest version of SQL Server that supported level 80 was SQL Server 2008(R2); which are also completely out of support. Considering that the compatibility and version of SQL server you are using differ so greatly, I'm surprised you do expect the same behaviour. – Larnu Sep 20 '19 at 8:35
  • 1
    At level 80, you're likely getting a compilation error. Your CATCH clause can't save you because the code doesn't even compile, let alone run or enter the TRY block. – Damien_The_Unbeliever Sep 20 '19 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.