Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:45:58+00:00 2026-06-02T06:45:58+00:00

Given the following SP … CREATE PROCEDURE [dbo].[trytest1] AS — SET NOCOUNT ON added

  • 0

Given the following SP …

CREATE PROCEDURE [dbo].[trytest1]

AS

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

SELECT 'Testing 1'

DECLARE @int1 INTEGER
DECLARE @int2 INTEGER
DECLARE @int3 INTEGER

SET @int1 = 0
SET @int2 = 0

    BEGIN TRY
        SELECT 'Testing 2'

        SET @int3 = @int1 / @int2

        SELECT 'Testing 3'
    END TRY

    BEGIN CATCH
        SELECT 'Testing 4'
    END CATCH

SET @int3 = @int1 + @int2
SELECT 'Testing 5'

Executing this gives …

Testing 1

Testing 2

Testing 4

Testing 5

Return Value -6

Catch catches divide by zero, but execution continues after catch block
Im curious why even though query executed successfully and
continued after the trycatch normally, the return value is -6. Will it stay -6 forever?

And, while I’m here, just curious, is it possible to continue execution in Try Block (ie select ‘Testing 3’)

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:45:59+00:00Added an answer on June 2, 2026 at 6:45 am

    that’s the standard behavior on all exception handling mechanisms. You have a TRY and a CATCH and code in between. If you have an exception in the code, it stops from running and go to the CATCH block.

    If you want the SELECT 'Testing 3' to be executed, it must be placed outside the TRY…CATCH block.

    If you dont want to execute anything else on the proc, you either put everything on the TRY…CATCH block OR exists the execution on the catch block

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following tables: CREATE TABLE #USGS_24K_TOPOMAP_BOUNDARIES( [OBJECTID] [int] NOT NULL, [AREA] [numeric](38, 8)
Given the following XML, <Container> <Set > <RecommendedCoverSong>Hurt by NiN - Johnny Cash</RecommendedCoverSong> <RecommendedOriginalSong>She
Given the following table partitioning under PostgreSQL 9.0.3: CREATE TABLE records ( ts TIMESTAMP,
Given the following classes: class Department { public String Name { get; set; }
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?
Given the following example (using JUnit with Hamcrest matchers): Map<String, Class<? extends Serializable>> expected
Given the following two ways of defining a class method in Ruby: class Foo
Given the following list of presidents do a top ten word count in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.