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.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | sanjay5219Posting Yak  Master
 
 
                                        240 Posts | 
                                            
                                            |  Posted - 2013-07-19 : 09:01:17 
 |  
                                            | Hi All,Result of this query is returning 0 actually I need 0.04 as an answer.Select cast(4/95 as float)Please suggest |  |  
                                    | sanjay5219Posting Yak  Master
 
 
                                    240 Posts | 
                                        
                                          |  Posted - 2013-07-19 : 09:07:04 
 |  
                                          | ThanksSelect Cast(1 as Decimal)/Cast(3 as Decimal) |  
                                          |  |  |  
                                    | James KMaster Smack Fu Yak Hacker
 
 
                                    3873 Posts | 
                                        
                                          |  Posted - 2013-07-19 : 10:47:18 
 |  
                                          | As you found out, this is because of integer division.  If any one of the participants in the arithmentic expression are of floating point type, then that will force non-integer division. So for example, people do this: SELECT 4.0/95Also, when you cast to DECIMAL, give a precision and scale so you know what you are getting rather than letting SQL Server default. |  
                                          |  |  |  
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts |  |  
                                    | James KMaster Smack Fu Yak Hacker
 
 
                                    3873 Posts | 
                                        
                                          |  Posted - 2013-07-20 : 16:38:29 
 |  
                                          | Another perspective: http://myshallowsqlblog.wordpress.com/size-does-matter/ |  
                                          |  |  |  
                                |  |  |  |