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 |
|
Rita Bhatnagar
Posting Yak Master
172 Posts |
Posted - 2001-12-04 : 12:40:09
|
| How do i do this in sql server.FORMAT(SUM(A.NetChargeAR), '###,###,###.00') AS Amountif i do like this it does not give me commas.select Convert(dec(12,2),SUM(A.NetChargeAR)) |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2001-12-04 : 12:44:46
|
| You have two options/functions: STR() and CONVERT(). STR() is more flexible for converting numbers to formatted strings, but it does not put in commas. CONVERT() has some special format codes that WILL put in the commas, but it does not provide flexibility regarding decimal places. I'll think you'll be fine with CONVERT(), but read both of these functions in Books Online and test them so you know which will work for you. |
 |
|
|
Rita Bhatnagar
Posting Yak Master
172 Posts |
Posted - 2001-12-04 : 13:30:24
|
| How do we put commas with convert?I couldn't find it in bol.thanks. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2001-12-04 : 14:26:50
|
| You have to look after the section with the date format codes:In the following table, the column on the left represents the style value for money or smallmoney conversion to character data.Value Output 0 (default) No commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 4235.98. 1 Commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 3,510.92. 2 No commas every three digits to the left of the decimal point, and four digits to the right of the decimal point; for example, 4235.9819. |
 |
|
|
Rita Bhatnagar
Posting Yak Master
172 Posts |
Posted - 2001-12-04 : 17:38:41
|
| Thanks.rita |
 |
|
|
|
|
|
|
|