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 |
wided
Posting Yak Master
218 Posts |
Posted - 2010-10-01 : 04:52:55
|
in database, i stock hour (int)exemple 1290 with calculate or MS excel, if i do 1290/60 i have 21.5with sql, i have 21 without .5why?i need helpthanks |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-01 : 05:08:38
|
it's an implicit conversion to integer arithmatic.TrySELECT 1290/60.0 And you'll get 21.5If you need to do this in a set (for int columns) cast them to FLOAT or DECIMALExampleSELECT [Col1] / CAST([col2] AS FLOAT)FROM <ExampleTable> Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-01 : 05:09:01
|
select 1290/60 -- gives 21select 1290/60.0 -- gives 21.500000 No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-01 : 05:09:27
|
No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
|
|
|