Round to 2 decmial places

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muddasirmunir
    Contributor
    • Jan 2007
    • 284

    #1

    Round to 2 decmial places

    I am using SQL Server 2000.

    I had made a filed name quanity , type numeric with scale =2

    Now currently its showing me data like this.

    Code:
    10
    10.3
    115.98
    100.1
    If you notice it will remove the last number if '0'

    I want to be it like


    Code:
    10.00
    10.30
    115.98
    100.10
    There is a code i know in vb6 , that can do that
    Code:
    Format(Round(quantity.Text, 2), "##0.00")
    but how can we do that in SQL Server databes.
  • viktorka
    New Member
    • Jun 2010
    • 26

    #2
    Originally posted by muddasirmunir
    I am using SQL Server 2000.

    I had made a filed name quanity , type numeric with scale =2

    Now currently its showing me data like this.

    Code:
    10
    10.3
    115.98
    100.1
    If you notice it will remove the last number if '0'

    I want to be it like


    Code:
    10.00
    10.30
    115.98
    100.10
    There is a code i know in vb6 , that can do that
    Code:
    Format(Round(quantity.Text, 2), "##0.00")
    but how can we do that in SQL Server databes.
    If you want to see it directly in the SQL, I donot think you can do it. I would go around and created SQL View where you may use CAST(quantity as smallmoney)

    Or you may try to set column tyme to smallmoney or money if you need 2 decimals only.

    Comment

    Working...