Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2012-05-17 : 10:13:38
|
Hi,How do I format a number to have thousand separater as well as rounding it to 2 decimal places?At present I can round it but not sure how to place thousand separater.Can you assis please?Thanks |
|
malpashaa
Constraint Violating Yak Guru
264 Posts |
Posted - 2012-05-17 : 10:26:37
|
You have to convert it to money (or smallmoney) at first, then convert it to char/varchar using style 1Example:SELECT CONVERT(VARCHAR(MAX), CONVERT(MONEY, 1234.56), 1) For us, there is only the trying. The rest is not our business. ~T.S. EliotMuhammad Al Pasha |
 |
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2012-05-17 : 10:27:55
|
How do I specify decimal places in this please? |
 |
|
malpashaa
Constraint Violating Yak Guru
264 Posts |
Posted - 2012-05-17 : 10:40:32
|
quote: Originally posted by arkiboys How do I specify decimal places in this please?
You cannot. For more information read "money and smallmoney Styles" section of "CAST and CONVERT" [url]http://msdn.microsoft.com/en-us/library/ms187928.aspx[/url]For us, there is only the trying. The rest is not our business. ~T.S. EliotMuhammad Al Pasha |
 |
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2012-05-17 : 10:55:22
|
Thank you |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2012-05-22 : 13:22:32
|
quote: Originally posted by arkiboys Hi,How do I format a number to have thousand separater as well as rounding it to 2 decimal places?At present I can round it but not sure how to place thousand separater.Can you assis please?Thanks
Always return raw data from the database to your clients and format the number exactly as you want where you are presenting the output; i.e., on a Report, in an Application, on a web page, in Excel, etc.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|
|
|