thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Foundational

CAST Function

The ANSI SQL function that explicitly converts a value to another data type: CAST(expression AS type).

Definition

CAST performs explicit conversion and fails if the value cannot be converted. Vendors add alternatives such as CONVERT in SQL Server (with style codes), the :: operator in PostgreSQL and Snowflake, and TO_DATE or TO_NUMBER in Oracle.

Example

SELECT CAST('2026-11-01' AS DATE);

Exam tip

A failing CAST errors out the whole query; use TRY_CAST to return NULL instead.

Related terms