Results 1 to 6 of 6

Thread: Decimal points in Money data type(SQL 2K)

  1. #1
    Join Date
    Jul 2003
    Location
    NewJersey
    Posts
    2

    Decimal points in Money data type(SQL 2K)

    In SQL Server 2000 the data type "Money" has 4 decimal points. I defined Money type in few of our tables. If a table is opened in design, the datatype scale is grayed out and cannot be changed. Is it possible to supress it to 2 decimals using SQL? or else, Shall I have to convert to Decimal data type in our tables?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    The decimal places in Money datatype is fixed, you can't change it.

    If you want only 2 decimal places then you have to use DECIMAL datatype.

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    you can define it as money in the table and while selecting you can use Convert

    create table x (id int identity(1,1), cash money)

    insert into x (cash) select 100.245
    insert into x (cash) select 100.25
    insert into x (cash) select 100.24
    insert into x (cash) select 100.00
    insert into x (cash) select 100.12

    select convert(decimal(8,2),cash) from x

  4. #4
    Join Date
    Jul 2003
    Location
    NewJersey
    Posts
    2
    Thankyou all!

  5. #5
    Join Date
    Sep 2002
    Posts
    51
    You do not have to convert it to decimal, you can use the style paramater of convert. For example:

    declare MyMoney money
    set MyMoney = 12345.123
    print convert(varchar(20),MyMoney,0)
    print convert(varchar(20),MyMoney,1)
    print convert(varchar(20),MyMoney,2)

    Result:
    12345.12
    12,345.12
    12345.1230

  6. #6
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    knicholson.

    FYI.

    This thread is about sql server.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •