SQL Server Performance

Urgent: Using decimal type

Discussion in 'SQL Server 2005 T-SQL Performance Tuning' started by apskallen, Mar 8, 2007.

  1. apskallen New Member

    Hi,
    I have a problem that gives me quite a headache. I'm writing this code (simplified example):

    DECLARE @SumDECIMAL
    SET @Sum = 88.5

    SELECT @Sum

    This returns 89! How is that possible?

    Is there any way to get 88.5 by using CASTs, SET xxx, etc? I'm increasing a field in a table of type decimal and this gives me very strange errors...

    Thanks!
  2. MohammedU New Member

    DECLARE @Sum DECIMAL(5,1)
    SET @Sum = 88.5

    SELECT @Sum

    You should give scale number too... see BOL...


    MohammedU.
    Moderator
    SQL-Server-Performance.com
  3. FrankKalis Moderator

    If you don't specify a scale for a DECIMAL type, SQL Server will use a default type of DECIMAL(18,0).

    --
    Frank Kalis
    Moderator
    Microsoft SQL Server MVP
    Webmaster:http://www.insidesql.de

Share This Page