Try catch block in SQL statement not in T-SQL

  • Dear All,
    It is possible to use try..catch in SQL statement. below is the my query
    begin try
    select 1/0
    end try
    begin catch
    print 'error'
    end catch

  • That should work in SQL 2008.  What's the problem?

  • laurie-789651 - Thursday, July 26, 2018 5:37 AM

    That should work in SQL 2008.  What's the problem?

    If one divided by zero, then should be throw an error but print error message instead of 'No column name'

  • sunilkmr284 - Thursday, July 26, 2018 6:21 AM

    laurie-789651 - Thursday, July 26, 2018 5:37 AM

    That should work in SQL 2008.  What's the problem?

    If one divided by zero, then should be throw an error but print error message instead of 'No column name'

    Click on the messages tab and you will find it there.

    Sue

  • Sue_H - Thursday, July 26, 2018 6:26 AM

    sunilkmr284 - Thursday, July 26, 2018 6:21 AM

    laurie-789651 - Thursday, July 26, 2018 5:37 AM

    That should work in SQL 2008.  What's the problem?

    If one divided by zero, then should be throw an error but print error message instead of 'No column name'

    Click on the messages tab and you will find it there.

    Sue

    Thanks, it's there.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply