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)
 decimals and thousands

Author  Topic 

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-07-30 : 10:15:05
hi all.

i was wondering is it possible to to this:
i have a column PhysicalQty decimal(12,3)
which has the values stored in this format:
4321.345

i would like to format them into this:
4,321.345

i know it's possible to do it in the application (i'm doing it now :)), but it would be great if it could be done in sql.

and i can't change the db design.

Go with the flow & have fun! Else fight the flow :)

JasonGoff
Posting Yak Master

158 Posts

Posted - 2004-07-30 : 11:48:54
Application design principles Rule 1... data presentation is done in the presentation layer.
That way, you can easily localise your application (ie. have numbers displayed as 4.321,345 in countries where this separation is used) without having to redesign/rework any of the back-end.
Result is that a web-based application in multiple countries accessing the same database can have data presented in a format they are familiar with.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-07-30 : 17:30:22
yeah i know all that :))) but this sql is for testing purposes, so i was just wondering if it can be done in a similar way dates can be formated with convert().

if not, no big deal...

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

Kristen
Test

22859 Posts

Posted - 2004-07-31 : 01:50:35
Well you could do something really crappy like:
REPLACE(CONVERT(varchar(20), CONVERT(money, CONVERT(int, PhysicalQty)), 1), '.00', '') + REPLACE(CONVERT(varchar(20), PhysicalQty- CONVERT(int, PhysicalQty)), '0.', '.')

Kristen
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-07-31 : 07:42:30
Kristen: that's great, thanx.
i don't care if it's crappy, because i'll run it only once...maybe twice

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

- Advertisement -