SQL CONVERT Function

Example

Convert an expression to int:

SELECT CONVERT(int, 25.65);

Definition and Usage

The CONVERT() function converts a value (of any type) into a specified datatype.

Tip: Also look at the CAST() function.

Syntax

CONVERT(data_type(length), expression, style)

Continue reading SQL CONVERT Function

SQL CAST Function

Example

Convert a value to an int datatype:

SELECT CAST(25.65 AS int);

Definition and Usage

The CAST() function converts a value (of any type) into a specified datatype.

Tip: Also look at the CONVERT() function.

Syntax

CAST(expression AS datatype(length))

Continue reading SQL CAST Function