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)
 Formatting in T-SQL

Author  Topic 

missMac
Posting Yak Master

124 Posts

Posted - 2009-09-10 : 22:11:00
Hello guys,
we normally format our data in our front end.

But Am wondering, if MSSQL can format integers, such that.

1000 will appear as 1,000

e.g.

select currency from products where currency > 999

thanks

MM


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-09-10 : 22:18:07
what is the data type for currency ? integer or money ?

if it is integer, convert to money first, then convert to string with format style 1

select convert(varchar(10), currency, 1)
from products
where currency > 999



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

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-11 : 02:58:26
Note that 1,000 is a varchar and not to be treated as a number

Madhivanan

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

- Advertisement -