19

As the title says. I even tried SELECT CONVERT(NUMERIC, 1/2) which also returned 0.

I am using SQL Server 2008.

29

They're integers.

Try:

select 1.0/2.0;

Or:

select CONVERT(NUMERIC,1)/CONVERT(NUMERIC,2);
14

First, you are executing the numbers as integers but second, you also have not defined the precision and scale of the numeric datatype.

Try this:

SELECT CONVERT(NUMERIC(5, 2), 1.0/2.0)

or even

SELECT CONVERT(NUMERIC(5, 2), 1/2.0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.