Results 1 to 4 of 4

Thread: Can I convert decimal to string for mssql server?

  1. #1
    Join Date
    Apr 2008
    Posts
    53

    Can I convert decimal to string for mssql server?

    Hi,

    I have a really simple question. I want to know the real difference between the decimal & the Money datatype.
    Is it possible to convert the string value to decimal?
    Basically I want to know the conversion of decimal datatype to string?
    Can I convert decimal to string for mssql server?
    I hope am not making any confusing question here for mssql.

    Thanks,
    Waffle

  2. #2
    Join Date
    Aug 2008
    Posts
    90

    Re: Can I convert decimal to string for mssql server?

    lets talk about decimal & money first.
    Money was specifically designed for currency with dollar and cent format. If you do math with 2 decimals then you must use the significant digits for proper evaluation. The obvious difference is that the decimal data type offers much greater precision. if you're not going to do anything to the values other than add or subtract... no problems. If you're going to do anything else (like multiply or divide), you'll need at least 4 decimal places to do the calculations without loosing overall accuracy.

  3. #3
    Join Date
    Apr 2008
    Posts
    42

    Re: Can I convert decimal to string for mssql server?

    MONEY (smallmoney and CURRENCY) is faster, since they really are INTs (scaled down by 10000). US MONEY is best as only 4 decimal places are required for rounding. I have a same question to you guy does Money avoid rounding issues?
    i prefer decimal in most cases.
    If I'm storing pricing or something else that is in monetary units, I use money. But I still prefer decimal more than money.
    It should be decimal since you can set precision and scale numbers. Precision is the number of decimal places that the column can take; scale is the number of decimal places allowed to the right of the decimal point.

  4. #4
    Join Date
    May 2008
    Posts
    29

    Re: Can I convert decimal to string for mssql server?

    Convert decimal to string use cast:

    Code:
    SELECT cast(lotSize as varchar(100) ) + ' ' + lotSizeType AS lotSize
    FROM Listings
    OR

    Code:
    select replace(space(1)+replace(cast (6.250 as varchar),'.',''),' ','0')

Similar Threads

  1. Replies: 3
    Last Post: 27-11-2010, 12:59 AM
  2. Convert float to 2 decimal place
    By SoftWore in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 01:22 PM
  3. c program to convert decimal to binary
    By Oswaldo in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 03:45 PM
  4. Convert binary to decimal in java
    By Seraphim in forum Software Development
    Replies: 2
    Last Post: 20-05-2009, 09:19 AM
  5. Convert a string in decimal
    By FlayoFish in forum Software Development
    Replies: 3
    Last Post: 23-04-2009, 12:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,797,981.42692 seconds with 16 queries