# How to write a cast statement in SQL?

Use the SQL CAST function by writing CAST(expression AS target_data_type) . The expression is what you want to convert, and target_data_type is the new type you want the result to have.

Bron: [SQL CAST() Function: Syntax, Usage, and Examples - Mimo](https://mimo.org/glossary/sql/cast-function#:~:text=Use%20the%20SQL%20CAST%20function%20by%20writing%20CAST(expression%20AS,want%20the%20result%20to%20have.)

Onderwerp: [Techniek & internet](https://1001vragen.nl/onderwerp/techniek-en-internet)
Toegevoegd: 2026-01-26
Webpagina: https://1001vragen.nl/vraag/how-to-write-a-cast-statement-in-sql

## How to write cast in SQL?

- These functions convert an expression of one data type to another. ...
- CAST syntax: CAST ( expression AS data_type ( ( length ) ) )
- CONVERT syntax: CONVERT ( data_type ( ( length ) ) , expression ( , style ) )
- Transact-SQL syntax conventions. ...
- Any valid expression. ...
- The target data type.

Bron: [CAST and CONVERT (Transact-SQL)](https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver17)

## What is a cast statement?

A cast is a mechanism that converts a value from one data type to another data type. Casts allow you to make comparisons between values of different data types or substitute a value of one data type for a value of another data type.

Bron: [What is a cast? - IBM](https://www.ibm.com/docs/en/informix-servers/14.10.0?topic=casts-what-is-cast#:~:text=A%20cast%20is%20a%20mechanism,value%20of%20another%20data%20type.)

## Verwante vragen

- [How to write greater than in SQL query?](https://1001vragen.nl/vraag/how-to-write-greater-than-in-sql-query.md)
- [How to write a number in SQL?](https://1001vragen.nl/vraag/how-to-write-a-number-in-sql.md)
- [How to write a case in Oracle SQL?](https://1001vragen.nl/vraag/how-to-write-a-case-in-oracle-sql.md)
- [How to write select query with where clause in SQL?](https://1001vragen.nl/vraag/how-to-write-select-query-with-where-clause-in-sql.md)
- [How do you write a metathesis rule?](https://1001vragen.nl/vraag/how-do-you-write-a-metathesis-rule.md)
- [What does SELECT cast do?](https://1001vragen.nl/vraag/what-does-select-cast-do.md)
- [What is the CAST function in Oracle?](https://1001vragen.nl/vraag/what-is-the-cast-function-in-oracle.md)
- [How to use cast statement in SQL?](https://1001vragen.nl/vraag/how-to-use-cast-statement-in-sql.md)
- [How to cast a bit in SQL?](https://1001vragen.nl/vraag/how-to-cast-a-bit-in-sql.md)
- [How to use the CAST function in SQL?](https://1001vragen.nl/vraag/how-to-use-the-cast-function-in-sql.md)
