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 |
vishakha209
Starting Member
2 Posts |
Posted - 2007-06-19 : 05:52:48
|
Select (45/10) returns value 4.R8 ans is 4.5I need to convert either 45 to decimal or write 10 as 10.00Is any other solution where no need to change datatype? |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-06-19 : 05:53:42
|
Select 1.0*(45/10)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
vishakha209
Starting Member
2 Posts |
Posted - 2007-06-19 : 05:54:57
|
Any solution using SQL? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-19 : 06:02:32
|
quote: Any solution using SQL?
What nr posted is SQL. What are you expecting ? KH |
 |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-06-19 : 06:51:10
|
The precision of the calculation is decided by the operands. If you have all integer operands then the arithmetic will be integer. The only way round this is to convert one of the operands to another datatype or to introduce another operand with a different datatype (of higher precedence) which doesn't affect the calculation.soSelect 1.0*(45/10)Select (45.0/10)Select (conver(decimal(18,2),45)/10)Select (convert(float,45)/10)could all be what you want depending on the precision you need.There's no way of changing the calculation precision without telling the server what you want.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
marginerazvan
Starting Member
14 Posts |
Posted - 2007-06-20 : 03:49:44
|
You can use $Select ($45/10)and the result will be 4.500You can use $ when you deal with divide / |
 |
|
|
|
|