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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How do I format number 50000 to 50,000?

Author  Topic 

multiplex77
Starting Member

24 Posts

Posted - 2007-10-21 : 04:40:49
Hi,

Is there a way in T-SQL for me to format the output of integers to include comma separators?

e.g.,

SELECT COUNT(TableID)
FROM TableWithManyRows

I want the count to display as 50,000 instead of 50000. Is this possible? Thanks for the advice.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-21 : 05:10:39
can you do this in your front end application ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-21 : 05:15:54
It is better to do this in your front end application, unless if you absolutely, whatsoever, have to, must do it in T-SQL . . .
select replace(convert(varchar(20), convert(money, 50000), 1), '.00', '')



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

multiplex77
Starting Member

24 Posts

Posted - 2007-10-21 : 05:41:20
Thanks KH that worked.

Just curious, why is it better to do it in the front end?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-21 : 05:48:56
read this thread http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76862


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

multiplex77
Starting Member

24 Posts

Posted - 2007-10-21 : 05:58:08
Thanks KH.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 02:58:50
quote:
Originally posted by multiplex77

Thanks KH that worked.

Just curious, why is it better to do it in the front end?


If you use front end application, you should use format function there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -