Groups | Blog | Home
all groups > sql server (alternate) > may 2004 >

sql server (alternate) : floating point calculation


nevermind NO[at]SPAM iname.com
5/7/2004 4:34:21 PM
I'm trying to perform a calculation on a field in SQL Server that
should return a value with a decimal point. My problem is that the
value returned is truncated without the decimal point. Is there a
setting that needs to be turned on in SQL server to allow this?

for example

Select 20/3

should return 6.6666667

Greg D. Moore (Strider)
5/7/2004 11:40:11 PM

[quoted text, click to view]

No, you should get 6.

Try select 20.0/3.0

You'll get 6.666666

When you say select 20/3 you're telling SQL Server you're starting with
ints, so it converts the answer to an int.

[quoted text, click to view]

AddThis Social Bookmark Button