Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 SQL Server'05 automatically rounding tha numbers

Author  Topic 

Muhammad Nasir
Starting Member

10 Posts

Posted - 2011-02-02 : 18:08:38
Hi.
I'm having a funny thing happening with sql query. Please have a look at the following query and help me out to resolve this

Select 1/2 as myCol

and the result i get is "0". Which means that sql server is automatically rounding tha data

when i write the above mentioned query as below

Select 1/2.0 as myCol

Now i get the proper and desired result. I'm wondering that why SQL Server 2005 is behaving like this ? Is it got something to do with Collation settings or something else need to be done to fix it ?

please help me on this

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-02-02 : 18:25:22
Here you go: http://sqlblogcasts.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Muhammad Nasir
Starting Member

10 Posts

Posted - 2011-02-03 : 23:14:10
Thanxs tkizer.. It was really helpful and informative.
Go to Top of Page
   

- Advertisement -