SQL Type-casting SQL Type-casting database database

SQL Type-casting


Under the covers there's no difference in implementation. The implicit casts accomplish the same thing as your explicit casts.


Since you write 0.0, TSQL interprets this as float value. All following ints are implicitly cast to float.

See also the implicit data type conversion matrix in the section Implicit Conversions


Not sure something being shorter is more readable since true reading involves comprehension.

SELECT CAST(5 AS FLOAT)/CAST(2 AS FLOAT);

There really is no doubt what the intention is here and will be understood when you come back to the code 6 months from now or when another developer looks at it for the first time.