Re: Divide By Zero Error Trapping
From: John Bell (jbellnewsposts_at_hotmail.com)
Date: 04/08/04
- Next message: Jan Hvarfvenius: "Re: Running total with a twist"
- Previous message: Guy Brom: "Re: EM doesn't Refresh the database properly"
- In reply to: Raymond D'Anjou \(raydan\): "Re: Divide By Zero Error Trapping"
- Next in thread: Louis Davidson: "Re: Divide By Zero Error Trapping"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Apr 2004 09:09:50 +0100
I did not put a string in there as you may well be expecting an integer
datatype that would possibly cause AVs in the Front End.
SELECT CASE WHEN @val = 0 THEN 0 ELSE 1/@val END AS Value,
CASE WHEN @val = 0 THEN 'Divide by Zero' ELSE 'ok' END AS ZeroDivide
or possible the following if you handle nulls in the F/E
SELECT CASE WHEN @val <> 0 THEN 1/@val END AS Value
John
"Raymond D'Anjou (raydan)" <raydan@canatrade.nospamcom> wrote in message
news:uJFAvMMHEHA.2720@TK2MSFTNGP11.phx.gbl...
> Or, if a 0 result has to be differentiated from division by 0:
> > SELECT CASE WHEN @val = 0 THEN 'division by 0' ELSE CAST(1/@val AS
> VARCHAR(15)) END AS Value
>
> "John Bell" <jbellnewsposts@hotmail.com> wrote in message
> news:O3YlvBMHEHA.3576@TK2MSFTNGP10.phx.gbl...
> > You may want to try something like:
> >
> > DECLARE @val int
> > SET @val = 0
> >
> > SELECT CASE WHEN @val = 0 THEN 0 ELSE 1/@val END AS Value
> >
> > John
> >
> > "Gjones" <anonymous@discussions.microsoft.com> wrote in message
> > news:1985901c41cba$92eff270$a501280a@phx.gbl...
> > > I am using a query that contains an aggregate calculation:
> > >
> > > SUM(Sales * [%Br Incr Sales Selling] / [%ACV])
> > >
> > > Some of my fields have zeros.
> > >
> > > Thanks,
> > >
> > > Greg
> >
> >
>
>
- Next message: Jan Hvarfvenius: "Re: Running total with a twist"
- Previous message: Guy Brom: "Re: EM doesn't Refresh the database properly"
- In reply to: Raymond D'Anjou \(raydan\): "Re: Divide By Zero Error Trapping"
- Next in thread: Louis Davidson: "Re: Divide By Zero Error Trapping"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|