You are here: Re: Format Number on Select « MsSQL Server « IT news, forums, messages
Re: Format Number on Select

Posted by Plamen Ratchev on 12/26/07 20:02

Formatting is normally the job of the presentation/reporting layer, where
this is done best.

If the price is numeric then one way is to cast it to the correct decimal
precision (note that rounding will occur):
SELECT CAST(5.0000 AS NUMERIC(10, 2))

If it is character data type, then:
SELECT LEFT('5.0000', LEN('5.0000') - 2),
STUFF('5.0000', LEN('5.0000') - 2, 2, '')

HTH,

Plamen Ratchev
http://www.SQLStudio.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация