Home Forums SQL Server 7,2000 T-SQL what is the difference between CAST and CONVERT Function? RE: what is the difference between CAST and CONVERT Function?

  • vyas (4/21/2008)


    Use the conversion functions, CAST and CONVERT, to convert expressions of one data type to another data type when these conversions are not performed automatically by Microsoft® SQL Server™ 2000. These conversion functions are also used to obtain a variety of special data formats. Either of the conversion functions can be used in the select list, in the WHERE clause, and anywhere an expression is allowed.

    Use CAST rather than CONVERT if you want Transact-SQL program code to comply with SQL-92. Use CONVERT rather than CAST to take advantage of the style functionality in CONVERT.

    ANSI 92 is only good if software vendors follow it. Try CAST from a VARCHAR to a DATE/TIME in Oracle and see what happens....

    People spend way too much time following a standard that isn't followed by the people writing the RDBMS's. Portability is a myth.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)