How to convert Varchar to INT

To convert a Varchar to INT uses sql conversion functions like cast or convert.

Syntax

CAST ( expression AS datatype [ ( length ) ] )

CONVERT ( datatype [ ( length ) ] , expression [ , style ] )


Examples

SELECT CAST('77788' AS INT);

SELECT CAST(CAST ('888.67' AS NUMERIC) AS INT);
SELECT CAST(CAST ('888.6789' AS NUMERIC(19,4)) AS INT);

SELECT CONVERT(INT, '888');
SELECT CONVERT(INT, CONVERT(NUMERIC, '888.45'));
SELECT CONVERT(INT, CONVERT(NUMERIC(19,4), '888.45'));