Division in SQL Server 7.0

Results 1 to 4 of 4

Thread: Division in SQL Server 7.0

  1. #1
    J.A.M Guest

    Default Division in SQL Server 7.0

    Here&#039;s an odd little bug that I can&#039;t seem to solve.<BR><BR>DECALRE variable FLOAT<BR><BR>Variable = (Another1/Another2)*100<BR><BR>Comes out as whole figure ONLY.<BR><BR>If I hard code: Variable = 6.76, it comes out fine.<BR>If I hard code: variable = 12/4, it&#039;s 3<BR>variable = 12/5 = 2<BR>variable = 12*5.52 = 66.24<BR><BR>So the decimal places are coming through fine, *HOWEVER* the moment I drop in something like A/B, it&#039;s rounding it off and dropping the decimals.<BR><BR>What gives?? ::very puzzled::

  2. #2
    Join Date
    Dec 1969

    Default RE: Division in SQL Server 7.0

    hmmm... I&#039;d expect that if you&#039;d use a backslash... <BR><BR>have you checked the documentation?<BR><BR>j

  3. #3
    Join Date
    Dec 1969

    Default Just to understand it good:

    with the following you have problems?<BR><BR>DECLARE @var1 float<BR>DECLARE @var2 float<BR>DECLARE @var3 float<BR>DECLARE @var4 float<BR>SELECT @var1 = 12<BR>SELECT @var3 = 6.55<BR>SELECT @var4 = 5.78<BR>SELECT @var2 = (@var3/@var4)<BR>PRINT @Var1*@Var2<BR><BR>It gives me as expeced 13.5986 (in the Queryanalyzer)<BR><BR>Did I understand your problem correct?<BR><BR>Peter

  4. #4
    Join Date
    Dec 1969

    Default RE: Just to understand it good:

    I tried the backslash, IE AB, but that fails. It&#039;s / or nothing.<BR><BR>Peter:<BR>DECLARE @var1 int<BR>DECLARE @var2 int<BR>DECLARE @var3 float<BR><BR>SELECT @var1 = 10<BR>SELECT @var2 = 100<BR>SELECT @var3 = @var1/@var2<BR><BR>This return 0<BR>12/5 = 2 (no decimal places)<BR><BR>But if I hard code:<BR>SELECT @var3 = 4.56, it comes through fine.<BR>If I hard code (ifnore var1+2) 10/100 - I lose the decimal places.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts