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-03-29 : 09:35:45
|
| Tim writes "SQL Server 2000 PersonalWin 2000 ProSorry but here's an easy one (which I can't figure out)..When getting the product of a fraction (i.e. SET x = 3/4) all that ever comes out is a big fat zero regardless of data type. What's going on???ThanksTim" |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2002-03-29 : 09:35:45
|
| Why don't you post your code? |
 |
|
|
billsox
Yak Posting Veteran
74 Posts |
Posted - 2002-03-29 : 10:38:43
|
| SQL Server is treating 3 and 4 as whole numbers. To get the answer you desire, try the following code:DECLARE @X DECIMAL(3, 2)SELECT @X = CAST(3 AS DECIMAL(3, 2)) / 4SELECT @XOr...DECLARE @X DECIMAL(3, 2)SELECT @X = 3 / (4 * 1.0)SELECT @XBoth of these methods will force SQL to treat @X as a value with decimal places. Hope this helps.Bill |
 |
|
|
|
|
|