joygomez
asked on
SQL unable to place calculation of 1/4 into a column (decimal (18,4)
In Sql Servicer, I am unable to do a calculation of 1/4 and place it in column with decimal (18,4). However when i place the value .25, it accepts it.
below is the query.
UPDATE ExactCostLaborTimings_Work ingTbl_Gra nular
SET ExactCostLaborTimings_Work ingTbl_Gra nular.Divi dingFactor =1/4
below is the query.
UPDATE ExactCostLaborTimings_Work
SET ExactCostLaborTimings_Work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's probably treating 1 and 4 as integers, losing precision, so the result is rounded to 0. Adding a decimal, like with 0.25 or 1/4.0 implicitly converts the values to a data type that preserves the fractional number. You could also use an explicit cast to do the same thing CAST(1 as decimal) / CAST(4 as decimal)
Never mind. Too late :-)
ASKER
That was quick! Thank you.