Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in SQL by (55.6k points)

Can anyone tell me how to convert varchar to int in SQL?

1 Answer

0 votes
by (119k points)

We can use CAST() function to convert not only varchar to int but also from any type to another type.

This is the syntax to change datatype using CAST():

CAST( expression AS datatype (length))

Here is the example of how to convert from varchar to int:

SELECT CAST (‘1234’ AS INT);

You can check this SQL tutorial blog to understand datatype conversions with examples.

Related questions

0 votes
1 answer
asked Jul 4, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
3 answers
0 votes
1 answer
0 votes
1 answer
asked Jul 24, 2019 in SQL by Tech4ever (20.3k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...