Converting Data Types with CAST()

In many situations, your DBMS will convert, or cast, data types automatically. It may allow you to use numbers and dates in character expressions such as concatenation, for example, or it will promote numbers automatically in mixed arithmetic expressions (see the DBMS Tip in “Performing Arithmetic Operations” earlier in this chapter). Use the CAST() function to convert an expression of one data type to another data type when your DBMS doesn’t perform the conversion automatically. For information about data types, see “Data Types” in Chapter 3.

The CAST() function’s important characteristics are:

  • Implicit conversions are those conversions that occur without specifying CAST(). Explicit conversions are those conversions ...

Get SQL: Visual QuickStart Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.