|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a price field that when I query it, it returns the price as
"5.0000". What function can I use to return the price as "5.00"? THANKS |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Erich93063 (erich93063@gmail.com) writes:
> I have a price field that when I query it, it returns the price as > "5.0000". What function can I use to return the price as "5.00"? str(). The syntax is str(val[, width[, scale]]) if memory serves. Look it up in Books Online for the exact details. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Dec 27, 12:30am, Erich93063 <erich93...@gmail.com> wrote:
> I have a price field that when I query it, it returns the price as > "5.0000". What function can I use to return the price as "5.00"? > > THANKS Where do you want to show data? If you use front end application, use format function there |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
cast( '5.0000' as decimal(9,2))
-- Sincerely, John K Knowledgy Consulting, LLC knowledgy.org Atlanta's Business Intelligence and Data Warehouse Experts "Erich93063" <erich93063@gmail.com> wrote in message news:5c976abd-e0a0-4f5d-8f02-ac697a516f75@t1g2000pra.googlegroups.com... >I have a price field that when I query it, it returns the price as > "5.0000". What function can I use to return the price as "5.00"? > > THANKS |
|
![]() |
| Outils de la discussion | |
|
|