INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a Computer / IT professional? Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Feedback
"...This site is a great forum to exchange knowledge..."
Geography
Where in the world do Tek-Tips members come from?
|
Microsoft SQL Server: Programming FAQ
|
T-SQL Hints and Tips
|
How do I format money/decimal with commas?
Posted: 29 Dec 05
|
Sometimes you want to have your money fields properly formatted with commas like this: 13,243,543.57 You can use the CONVERT function and give a value between 0 and 2 to the style and the format will be displayed based on that
Below is an example
CODEDECLARE @v MONEY SELECT @v = 1322323.6666
SELECT CONVERT(VARCHAR,@v,0) --1322323.67 Rounded but no formatting
SELECT CONVERT(VARCHAR,@v,1) --1,322,323.67 Formatted with commas
SELECT CONVERT(VARCHAR,@v,2) --1322323.6666 No formatting
If you have a decimal field it doesn't work with the convert function The work around is to convert it to money
CODEDECLARE @v2 DECIMAL (36,10) SELECT @v2 = 13243543.56565656
SELECT CONVERT(VARCHAR,CONVERT(MONEY,@v2),1) --13,243,543.57 Formatted with commas |
Back to Microsoft SQL Server: Programming FAQ Index
Back to Microsoft SQL Server: Programming Forum |
|
 |
|
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close