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
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.
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.
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')