Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Casting strings to int/smallint/bigint/tinyint yields null if the string isn't a 'pure' integer. '1.0', '2.4' all return null. I think for those cases the cast should return the truncated int (i.e.: if c is string, cast(c as int) should be the same as cast(cast(c as float) as int).
This is in line with the standard and is the same behavior as mysql and oracle. (postgres and sql server throw error, see first answer here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/af3eff9c-737b-42fe-9016-05da9203a667/oracle-does-understand-cast10-as-int-why-sql-server-does-not)