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_WorkingTbl_Granular
                  SET         ExactCostLaborTimings_WorkingTbl_Granular.DividingFactor =1/4
joygomezAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
The problem is that 1/4 in T-SQL is not a literal meaning 0.25. It is an expression meaning integer 1 diveded by integer 4. Thus the result is an integer. Thus 0.
You need to modify this expression to a wider type. It's pretty simple, while not obvious: 1 / 4.0.

So this should do it:

UPDATE ExactCostLaborTimings_WorkingTbl_Granular
SET    DividingFactor = 1/4.0;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_agx_Commented:
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)
_agx_Commented:
Never mind.  Too late :-)
joygomezAuthor Commented:
That was quick! Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.