MS SQL Server Division not returning Fractional Values

Sql Server Division Omits Fractional Values, why ?

 

MSSQL Server Numeric Division always raise confusions

eg. suppose we are executing

select 100 / 3

Result=33

not 33.333333

this is because division of int with another  int will be of data type int again

this is called implicit type casting , to acheive accurate results with fractional part change the above query with the following one

select cast (100 as float) / cast (3 as float)

Now Result will be 33.333333

the same thing can be do like this

select 100.00 / 3

Now Result will be again  33.333333

Here 100.00 will be treated as float with out explicitly type casting in to float, and there by float / int = float

abhilash

abhilash, is a programmer by profession and a technology addict with a passion towards browsing , shopping and imaging . My views may be biased on reviews. all images and videos are copyrighted to respective owners.

Add comment

Your Header Sidebar area is currently empty. Hurry up and add some widgets.