Re: it maybe a wrong return value



Please give the precision and scale while using decimal. See the below
example.

ALTER Function dbo.abc

(@ParamOne numeric(10,2), @ParamTwo numeric(10,2))

RETURNS Bit

AS

BEGIN

DECLARE @Result bit

if abs(@ParamOne-@ParamTwo)<0.01

SET @Result=1

else

SET @Result=0

RETURN @Result

END



Thanks

Hari

"Lorry Astra" <LorryAstra@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A86A320C-192C-4321-A4D4-05B32ADC3BD1@xxxxxxxxxxxxxxxx
There is a sql function like this below:

Create Function dbo.abc
(@ParamOne decimal, @ParamTwo decimal)
RETURNS Bit
AS
BEGIN
DECLARE @Result bit
if abs(@ParamOne-@ParamTwo)<0.01
SET @Result=1
else
SET @Result=0
RETURN @Result
END

if i execute this sentence: "select dbo.abc (2.12,2.11)" , why does the
function return 1 instead of 0?
Thanks.


Lorry


.



Relevant Pages

  • Re: increasing width
    ... which I get every time I want to declare real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: increasing width
    ... Some fellow over in sci.math.num-analysis tells me I can get at least 6 more sig figs, if instead of declaring as type real, I declare as real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: double confusion
    ... Modules that came in in Fortran 90, where you can just declare things "once at ... precision, but not for integer or real ... ... This reflects the implicit Typing of the languages - in C functions return ... Thus you must declare all double precision variables. ...
    (comp.lang.fortran)
  • Re: module problems
    ... You can *NOT* redeclare the information. ... double precision:: kbdoe,... ... There is no such external function; ... you need to declare the type like this. ...
    (comp.lang.fortran)
  • lang effort: type conversions
    ... the lang will be dynamically typed with a prototype ... long, either a fixnum or an on-heap object, with undefined precision (for ... will declare a mutable one. ...
    (comp.lang.misc)