You could use CAST or CONVERT:

SELECT CAST(MyVarcharCol AS INT) FROM Table

SELECT CONVERT(INT, MyVarcharCol) FROM Table
Answer from Christian C. Salvadó on Stack Overflow
Discussions

How do I convert these values (currently String) into INT (but with a catch)
Cast(case when value like ‘%>%’ then 600 else value end) as int More on reddit.com
🌐 r/SQL
9
16
February 12, 2022
How to convert or cast int to string in SQL Server - Stack Overflow
Looking at a column that holds last 4 of someone's SSN and the column was originally created as an int datatype. Now SSN that begin with 0 get registered as 0 on the database. How can I convert the More on stackoverflow.com
🌐 stackoverflow.com
Error on converting String to Integer
I am retrieving a number portion from a string and convert it to integer. CAST(LTRIM(RIGHT(ITEMNAME,2)) as int) Although that portion is definitely a number that could be cast into an Integer I get constantly the error message: Msg 245, Level 16, State 1, Line 1 Conversion failed when converting ... More on forums.sqlteam.com
🌐 forums.sqlteam.com
0
0
March 15, 2018
sql server - convert string to integer and round - Database Administrators Stack Exchange
The select diag_1 TRY_CONVERT is good but unfortunately i'm getting an error with the DECLARE, INSERT, with x AS. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 2 Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query · 1 Run SQL query with python in SQL Server raises error: SqlSatelliteCall error: Unsupported input data type in column · 4 Integer ... More on dba.stackexchange.com
🌐 dba.stackexchange.com
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › functions › cast-and-convert-transact-sql
CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
If you try an incorrect conversion, for example trying to convert a character expression that includes letters to an int, SQL Server returns an error message. When the CAST or CONVERT functions output a character string, and they receive a character string input, the output has the same collation ...
🌐
Steve Stedman
stevestedman.com › 2024 › 06 › converting-text-to-integer-in-sql-server
Converting Text to Integer in SQL Server
November 17, 2024 - SELECT CONVERT(INT, your_text_column) AS converted_integerFROM your_table; The CONVERT function is specific to SQL Server and provides more flexibility than CAST.
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-query-to-convert-varchar-to-int
SQL Query to Convert VARCHAR to INT - GeeksforGeeks
This conversion is necessary when we need to perform mathematical operations or comparisons on numeric values stored as strings. SQL Server provides several methods to achieve this, including CAST(), CONVERT(), and error-handling functions like ...
Published   July 23, 2025
🌐
MSSQLTips
mssqltips.com › home › sql convert int to string
SQL Convert INT to String
May 28, 2025 - So, by default, we need to convert OrderQty which is numeric into a string to be able to concatenate the string with the number. To do that, we will try different methods. The following example shows how to use the SQL CAST function for an int ...
Find elsewhere
🌐
InterSystems
docs.intersystems.com › irislatest › csp › docbook › DocBook.UI.Page.cls
TO_NUMBER (SQL) | InterSystems SQL Reference | InterSystems IRIS Data Platform 2026.1
CAST and CONVERT can be used to convert a string to a number of any data type. For example, you can convert a string to a number of data type INTEGER.
🌐
T-SQL Tutorial
tsql.info › sql › how-to-convert-string-to-int.php
How to convert String to INT in sql - T-SQL Tutorial
In SQL Server, you can convert a string to an integer using the CAST or CONVERT functions. Both functions allow you to convert data from one data type to another.
🌐
SQLTeam
forums.sqlteam.com › transact-sql
Error on converting String to Integer - Transact-SQL - SQLTeam.com Forums
March 15, 2018 - I am retrieving a number portion from a string and convert it to integer. CAST(LTRIM(RIGHT(ITEMNAME,2)) as int) Although that portion is definitely a number that could be cast into an Integer I get constantly the error…
🌐
W3Schools
w3schools.com › sql › func_sqlserver_convert.asp
SQL Server CONVERT() Function
The CONVERT() function converts a value (of any type) into a specified datatype. Tip: Also look at the CAST() function. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: ...
🌐
SQL Authority
blog.sqlauthority.com › home › sql server – convert text to numbers (integer) – cast and convert
SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT - SQL Authority with Pinal Dave
March 30, 2019 - SQL SERVER – FIX : Error : msg 8115, Level 16, State 2, Line 2 – Arithmetic overflow error converting expression to data type ... I want to convert ‘1,2,3,4,5,6,7,8,9,10,11,12’ this string to numeric when i convert it show ‘Error converting data type varchar to numeric’. plz helpReply ... SELECT CONVERT(INT, CONVERT(CHAR(10), GETDATE(),112 )) SELECT CAST(CONVERT(CHAR(10), GETDATE(), 112) AS INT)Reply
🌐
W3Schools
w3schools.com › sql › func_sqlserver_cast.asp
SQL Server CAST() Function
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... The CAST() function converts a value (of any type) into a specified datatype. Tip: Also look at the CONVERT() ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › data-types › data-type-conversion-database-engine
Data type conversion (Database Engine) - SQL Server | Microsoft Learn
In this case, the string 1 can be converted to the integer value 1, so this SELECT statement returns the value 2. The + operator becomes addition rather than concatenation when the data types provided are integers. Some implicit and explicit data type conversions are not supported when you are converting the data type of one SQL Server object to another.
🌐
C# Corner
c-sharpcorner.com › blogs › convert-integer-to-string-in-sql-server
Convert Integer to String in SQL Server
March 14, 2023 - The CAST function can be used to convert an integer to a string. The syntax for this function is as follows: ... Output to the above SQL statement is shown below in Figure 1. ... The CONVERT function can also convert an integer to a string.
🌐
Sqlrevisited
sqlrevisited.com › 2024 › 08 › how-to-convert-string-to-integer-sql.html
SQLrevisited: How to convert String to Integer SQL? Example Tutorial
August 21, 2024 - Anyway, SQL CONVERT capability runs somewhat better compared to the SQL CAST capability · To cast VARCHAR to INT in MySQL, we can use in-built CAST() function. Syntax for the same is given below: ... We will use TO_NUMBER function to convert ...
🌐
StrataScratch
stratascratch.com › blog › what-are-the-steps-to-cast-int-in-sql-for-type-conversion
What Are the Steps to Cast INT in SQL for Type Conversion? - StrataScratch
July 5, 2024 - The standard SQL function for conversion supported in all databases is CAST() or CAST AS SQL Function. Another function that does the same job is CONVERT(), but it’s SQL Server-specific.