Decimal data type

  • All,

    I have a column configured as data type decimal, precision 10, scale 10.

    If I try to enter 1.0 I get the error "the value you entered is not consistent with the data type or length of the column."

    I've also tried different configurations of precision and scale but always get the same error.

    Can anyone offer any advice on what I'm doing wrong?

    Thanks

  • DECLARE @d DECIMAL(10,10)

    SET @d = 1.0

    --fails

    DECLARE @d DECIMAL(20,10)

    SET @d = 1.0

    --works fine!

    This is for sql 2005 but it's still relevant to sql 2000.

    http://msdn.microsoft.com/en-us/library/ms187746.aspx

  • AFAIK, if you assign these to the same value, you can only store decimals. The scale (2nd param) is allowing for that many decimal points to the right, which means that a whole number doesn't fit.

    These both work:

    DECLARE @d DECIMAL(10,10)

    SET @d = 0.1

    GO

    DECLARE @d DECIMAL(11,10)

    SET @d = 1

  • Your correct. I eventually found it in BOL.

    The first number specifies how many digits are available for the integer and decimal parts combined and the second specifies the number used for the decimal. So 8,8 means 8 digits for the combined parts and 8 are taken for the decimal so there are no digits for the integer.

    Thanks

    Andrew

Viewing 4 posts - 1 through 3 (of 3 total)

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