[dba-SQLServer] conversion mystery

Susan Harkins ssharkins at gmail.com
Wed Jan 16 12:22:04 CST 2008


The following expression

SickLeaveHours/8

returns whole numbers because SickLeaveHours is an int column -- at least, I 
believe that's the reason.

I've tried the following:

CAST(SickLeaveHours/8 As decimal(6,4)) As SickHoursUsed

but it still returns a whole value, just with four decimal places, all 
sporting 0's. I've tried numeric, with the same results. I want this 
expression to return valid decimal values -- for instance, 69/8 = 8.625. I'm 
getting 8.0000

Also, I'd really like to discuss this percision, scale business -- I don't 
get it at all. I don't understand how the two interact -- for instance, in 
the above decimal(5,4) returns an error, but 6,4 doesn't.

Susan H. 




More information about the dba-SQLServer mailing list