Announcement

Collapse
No announcement yet.

Stored Procedure Try Catch blocks

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stored Procedure Try Catch blocks

    I came across a site which recommended enclosing SPs in Try/Catch as below. Any thoughts and/or additional suggestions?:

    BEGIN TRY
    SELECT 1/0
    END TRY
    BEGIN CATCH
    SELECT ERROR_NUMBER() AS ErrorNumber
    ,ERROR_SEVERITY() AS ErrorSeverity
    ,ERROR_STATE() AS ErrorState
    ,ERROR_PROCEDURE() AS ErrorProcedure
    ,ERROR_LINE() AS ErrorLine
    ,ERROR_MESSAGE() AS ErrorMessage;
    END CATCH

  • #2
    Please note that you can choose to use/not use the TRY, CATCH SQL. For more information, please refer to - https://msdn.microsoft.com/en-us/library/ms175976.aspx

    Comment

    Working...
    X