• Hi Chris,

    SQL Server tries to guess the data type of your constants. For 16.0000000385802490 it guesses numeric(18,16), for 16.000000038580249 it guesses numeric(17,15). You could get back the same result if you do explicit casting:

    select CAST(16.0000000385802490 AS datetime)

    , CAST(cast(16.000000038580249 as numeric(18,16)) AS datetime)

    I reckon when these data types are cast to float, there is a difference:

    select CAST(16.0000000385802490 AS float)

    , CAST(16.000000038580249 AS float)

    , CAST(cast(16.000000038580249 as numeric(18,16)) AS float)

    ---------------------- ---------------------- ----------------------

    16.0000000385803 16.0000000385802 16.0000000385803

    🙂

    ps: you can explore the types of literals using the sql_variant_property:

    select sql_variant_property(16.0000000385802490,'BaseType' )

    , sql_variant_property(16.0000000385802490,'Precision ' )

    , sql_variant_property(16.0000000385802490,'Scale' )

    select sql_variant_property(16.000000038580249,'BaseType' )

    , sql_variant_property(16.000000038580249,'Precision' )

    , sql_variant_property(16.000000038580249,'Scale' )

    It is interesting I agree 🙂

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software