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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-05-02 : 10:46:14
|
| Phil writes "Hi,I am trying to work with a real datatype. I get back the value of 7.8499999. All I really want is 7.85. Is there a way using the round function or something else that I can just get back 7.85 w/out all the trailing zero's (like 7.850000)?Thanks,Phil" |
|
|
aclarke
Posting Yak Master
133 Posts |
Posted - 2002-05-02 : 11:19:29
|
| select cast(round(100.6523523532, 0) as integer) |
 |
|
|
aclarke
Posting Yak Master
133 Posts |
Posted - 2002-05-02 : 11:24:29
|
quote: select cast(round(100.6523523532, 0) as integer)
Sorry, I didn't completely read your question. You want digits after the decimal place. I generally clean up these numbers in my application so I don't worry about it in SQL Server. |
 |
|
|
jbkayne
Posting Yak Master
100 Posts |
Posted - 2002-05-02 : 11:31:05
|
| From BOL:Numeric data types with fixed precision and scale.decimal[(p[, s])] and numeric[(p[, s])]-------------------select convert(decimal(18,2),7.8499999)To make this more generic, I set the precistion to the default of 18. In this case you could get away with a precision of 3. |
 |
|
|
aclarke
Posting Yak Master
133 Posts |
Posted - 2002-05-02 : 11:40:03
|
quote: decimal[(p[, s])] and numeric[(p[, s])]
Spiffy, thanks jbkayne. I was too lazy to look this one up and didn't have it in my head... |
 |
|
|
|
|
|
|
|