Why does this work in SQL Server?

  • Hi,

    Any thoughts as to why these statements produce the same results (38 rows returned)? This does not work in Oracle re: passing a int datatype as a string?

    USE northwind

    select * from "order details"

    where productid = '11'

    select * from "order details"

    where productid = 11

    ... and for money datatype these are not the same ...

    USE northwind

    select * from "order details"

    where unitprice = 14

    select * from "order details"

    where unitprice = '14'

     

    Many thanks. Jeff

  • Check the execution plans when doing that. You'll see it doesn't actually always work (well anyways).

  • Automatic data type conversion. Certain datatypes are automatically casted when you have a comparison using two different types.

  • There's a chart of which data types are converted implicitly, which require explicit conversion, and which are not allowed in Books Online. Look for Cast and Convert.

  • Cast or Convert could be an issue but the main reason there is no INT datatype in Oracle, it uses NUMBER for all numeric data types including DOULBE that is not used in SQL Server.  Hope this helps.

    Kind regards,

    Gift Peddie

    Kind regards,
    Gift Peddie

  • Great.

    Many thanks. Jeff

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply