Skip to main content

TRY_CAST

Converts a value from one data type to another. Returns NULL on error.

See also: CAST

Syntax

TRY_CAST( <expr> AS <data_type> )

Examples

SELECT TRY_CAST(1 AS VARCHAR);

┌───────────────────────┐
│ try_cast(1 as string)
├───────────────────────┤
1
└───────────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today