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.
| Author |
Topic |
|
BitShift
Yak Posting Veteran
98 Posts |
Posted - 2007-01-22 : 11:46:31
|
| Ive got a char(10) field that holds currency values. How can format these to allways have 2 decimal places using either a cast or convert ? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-22 : 11:49:19
|
| select cast(yourcolumnnamehere as numeric(12, 2))Peter LarssonHelsingborg, Sweden |
 |
|
|
dnf999
Constraint Violating Yak Guru
253 Posts |
Posted - 2007-02-22 : 06:53:38
|
| how about if you have a variable amount i.e. it could be 12,14 digits in length, and you only want 2 decimal places? |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-02-22 : 08:04:57
|
| #1 -- always, always, always use correct datatypes to store your data. NEVER store currency values as a char(10).#2 -- do not format data in sql server, format your data at the presentation layer -- webpage, report, client application, etc. Return Money and DateTime and Decimal and Int datatypes from your database, and use the formatting features of your front end to format the data. That is -- retrieve DATA from the database, and PRESENT the data at the PRESENTATION layer. It almost even makes sense if you think about it !- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|
|