How Can I Multiple 2 Decimal Number in Sql ???

  • Hello

    How Can I Multiple 2 Decimal Number in Sql And 10 Digit of Precision ???

    declare @N1 decimal(25,10)

    declare @N2 decimal(25,10)

    declare @f decimal(25,10)

    Set @N1 = 11900000.12345678

    Set @N2 = 10000000.12345678

    Set @f = @N1 * @N2

    Select @f

    Display in Sql ======> 119000002703703.4972416000

    But With Calculator ===> 119000002703703.4972415765279684

    Thank's a lot

    Habiby

  • Let me change your T-SQL slightly

    declare @N1 decimal(20,10)

    declare @N2 decimal(20,10)

    declare @f decimal(38,14)

    Set @N1 = 11900000.12345678

    Set @N2 = 10000000.12345678

    Set @f = @N1 * @N2

    Select @f

    Answer is then 119000002703703.49724157652797

    Display in Sql ======> 119000002703703.4972416000

    But With Calculator ===> 119000002703703.4972415765279684

    To understand why this is happening refer to Books On Line:

    Precision, Scale, and Length (Transact-SQL)

    ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/fbc9ad2c-0d3b-4e98-8fdd-4d912328e40a.htm

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply