Which Datatype should I use??

  • I want change the data type of my Table. It has a Weight column with following description

    [Weight] [numeric](9, 4) NOT NULL,

    Now I want to allow 99999.99999 which data type should I use?? Please help its urgent

  • DECIMAL(10,5) 🙂


    I'm on LinkedIn

  • If you understand that NUMERIC is a precision and then a scale, then you'd know that you need NUMERIC(10,5). Read up on it here. I'd also suggest, instead of NUMERIC, use DECIMAL. There's no real difference, just clarity and compliance with ISO standards.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (12/11/2013)


    If you understand that NUMERIC is a precision and then a scale, then you'd know that you need NUMERIC(10,5). Read up on it here. I'd also suggest, instead of NUMERIC, use DECIMAL. There's no real difference, just clarity and compliance with ISO standards.

    Yes, I would have elaborated also but I was eating a sandwich at the time and typing one-handed. It was a nice sandwich though 😛


    I'm on LinkedIn

  • yayomayn (12/11/2013)


    Grant Fritchey (12/11/2013)


    If you understand that NUMERIC is a precision and then a scale, then you'd know that you need NUMERIC(10,5). Read up on it here. I'd also suggest, instead of NUMERIC, use DECIMAL. There's no real difference, just clarity and compliance with ISO standards.

    Yes, I would have elaborated also but I was eating a sandwich at the time and typing one-handed. It was a nice sandwich though 😛

    I can live with that, but next time, share.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Yes,

    DECIMAL(10,5) would be the good choice, as "10" stands for the Total Integer count allowed and the "5" stands for the scale where you can enter the max of .99999

    but one drawback is the "0" would be suffixed at all times when there is a space to occupy in the scale.

    create table testxxx(numbr decimal(10,5))

    insert testxxx(numbr) values(0.9)

    select * from testxxx

    Result

    ------

    0.90000

    whereas the expected might be 0.9

  • That's a formatting issue that should be dealt with in whatever application is reading this data.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (12/11/2013)


    That's a formatting issue that should be dealt with in whatever application is reading this data.

    Absolutely!

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thank you every one... I have used Decimal (10,5)

Viewing 9 posts - 1 through 8 (of 8 total)

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