Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

How do i display numbers to 2 decimal places in sql server

Options
  • 23-09-2008 4:09pm
    #1
    Closed Accounts Posts: 196 ✭✭


    How do i display numbers to 2 decimal places in sql server


    i have tried
    select cast(100 as decimal) as cost

    ie i want 100.00


Comments

  • Registered Users Posts: 2,494 ✭✭✭kayos


    SELECT CONVERT(MONEY,100) as cost

    But to be honest would this not be better off in your front end? Say your SQL Server region is set to the UK and your front end is one of those countries that use the 100,00 format...


  • Closed Accounts Posts: 196 ✭✭NedKelly


    when i run this i get it to 4 decimal places
    i only need two

    select CONVERT(MONEY,100) as cost

    100.0000

    i need
    100.00


  • Registered Users Posts: 1,193 ✭✭✭liamo


    Select Cast(100 as Numeric(10,2)) As SomeColName


  • Registered Users Posts: 2,494 ✭✭✭kayos


    NedKelly wrote: »
    when i run this i get it to 4 decimal places
    i only need two

    select CONVERT(MONEY,100) as cost

    100.0000

    i need
    100.00


    Again this is down to the settings. Works to two decimal places on my env.

    Still think you should leave this off to the front end.


Advertisement