RE: Ignore SQL Server errors?

From: Steve Norman (SteveNorman_at_discussions.microsoft.com)
Date: 03/07/05


Date: Mon, 7 Mar 2005 08:23:13 -0800

As suggested, I have written a small SP to throw the Divide by Zero error,
and catch it, then select a string to display (see below).
When this is run in Query Analyser I get the error thrown and displayed, and
also the string is returned in the grid view. What would you change to stop
this throwing up the error?

Thanks,
Steve

CREATE PROCEDURE [dbo].[divzero]
AS
        DECLARE @ErrNum int
        SELECT @ErrNum = 100/0

        SELECT @ErrNum = @@ERROR
                SELECT 'DivZero'
GO

"Cowboy (Gregory A. Beamer) - MVP" wrote:

> I would have to see the code, as a captured error should not throw up the
> stack. Is this a long running sproc? If so, you may actually have a timeout
> instead of an error thrown up. The easiest test would be to implement a sproc
> you know will only take a second but throw an error. Then, catch with @@ERROR
> and see if you still get the SqlException. If not, the problem is not SQL
> error handling.
>
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
> "Steve Norman" wrote:
>
> > Hi,
> >
> > I am executing a SQL Server SP to get a DataSet through SqlDataAdapter.Fill.
> > The problem I have is that sometimes the SP will throw a divide by zero
> > error which causes a SqlException, even though the error is handled in the SP.
> >
> > Is there anyway of stopping this error being thrown, as the SP will return
> > the correct data after the divide by zero error has occured? I have tried
> > setting ContinueUpdateOnError = True but this does not seem to do anything.
> >
> > Thanks,
> > Steve



Relevant Pages

  • IF field with a formula
    ... to use an IF field to prevent a divide by zero error and to display ... The fields are defined as number fields and bookmarked Text66, Text67, ... display nothing if Text67 is blank or 0. ...
    (microsoft.public.word.tables)
  • RE: Checking if a cell entry is correct before adding it to anothe
    ... I've corrected this by inserting random data. ... > 1) I'm very confused about how you could have gotten a divide by zero error. ... > 2) You need to use the formula in only one cell, as it will sum all of the ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Assemblers are for hiding your work , not for faster code .
    ... a little thing to divide a 64-bit integer by ... ATIME: CONVERT TIME TO ASCII ... STRING IN OUR "BCD" STRING BUFFER. ... The box I'm working on makes up to 20-second time delays with 1 ps ...
    (comp.arch.embedded)
  • Re: passing value from 1 form to another form
    ... > I am using access forms to create an application using VBA. ... > the value in this filed to use a divide a sum on another subform. ... > but this brings up always the divide by zero error. ... 1)Public Variable Declaration ...
    (microsoft.public.access.modulesdaovba)
  • 2.6.29: ivtv-vbi.c: divide-by-zero in compress_sliced_buf()
    ... to die with a divide by zero error in ivtv-vbi.c. ... RSP ...
    (Linux-Kernel)

Loading