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 2000 Forums
 Transact-SQL (2000)
 Format output from COUNT(*)

Author  Topic 

cgunner
Yak Posting Veteran

95 Posts

Posted - 2005-07-24 : 08:38:52
Is is possible to format the output on the COUNT function? i.e.
SELECT COUNT(*) FROM TABLE

Result
1,000,000

Instead of
1000000

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-24 : 09:05:18
this shuold really be done in the presentation layer.
you can format only money type in this way (without doing some fany substring functions)
SELECT convert(varchar(50), convert(money, COUNT(*)), 1) FROM TABLE

Go with the flow & have fun! Else fight the flow
Go to Top of Page

cgunner
Yak Posting Veteran

95 Posts

Posted - 2005-07-24 : 10:35:33
I am using the query to get row counts of tables. It is a bit difficult to read the count without the comma's.
Go to Top of Page

pwcphoto
Yak Posting Veteran

69 Posts

Posted - 2005-07-24 : 15:28:03
If you are using VBScript use the formatnumber function. FormatNumber(Count) and it will insert commas where needed.

Phil

-----------------------
I used to be a rocket scientist. Now I'm just a space cadet...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-25 : 01:51:48
Do this in your presentation layer
Which application are you using?

Madhivanan

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

cgunner
Yak Posting Veteran

95 Posts

Posted - 2005-07-25 : 09:03:51
Thanks for all the help. FormatNumber() did the trick.
Go to Top of Page
   

- Advertisement -