SQL Flow Field Guide

CAST & CONVERT

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

type conversion

What changes

Input
an expression and target type (and culture/style)
Output or change
converted value (TRY_ variants return NULL on failure)
Return type
Returns expression, translated to data_type.

Syntax at a glance

CAST ( expression AS data_type [ ( length ) ] )

Work example

Give an expression a deliberate SQL type at a boundary between storage, calculation, and display.

Prefer CAST for portable type conversion and use an explicit CONVERT style when text dates need a fixed format.

Check your work Conversion can round, truncate, overflow, or depend on a style, so verify the result type and value.

Practice SQL

Open in SQL Flow
SELECT CAST(12.345 AS decimal(6,2)) AS rounded_value, CONVERT(char(10), CONVERT(date, '2026-04-05'), 23) AS iso_date;

Open Microsoft Learn for full syntax, permissions, and details for your version.