Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 06-07-2009
Member
 
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
Reply With Quote
  #2  
Old 06-07-2009
Member
 
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.
Reply With Quote
  #3  
Old 06-07-2009
Member
 
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.
Reply With Quote
  #4  
Old 06-07-2009
Member
 
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')
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Can I convert decimal to string for mssql server?"
Thread Thread Starter Forum Replies Last Post
How to convert a decimal number into words in Excel using VBA? Gandhik Windows Software 3 27-11-2010 12:59 AM
Convert float to 2 decimal place SoftWore Software Development 3 26-11-2009 01:22 PM
c program to convert decimal to binary Oswaldo Software Development 3 25-11-2009 03:45 PM
Convert binary to decimal in java Seraphim Software Development 2 20-05-2009 09:19 AM
Convert a string in decimal FlayoFish Software Development 3 23-04-2009 12:18 PM


All times are GMT +5.5. The time now is 02:51 AM.