Use the convert function.

SELECT CONVERT(varchar(10), field_name) FROM table_name
Answer from Tobberoth on Stack Overflow
๐ŸŒ
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() ...
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
Format Number as Text
In a quarry how do I format a select statement so it returns a number value as text? More on community.spiceworks.com
๐ŸŒ community.spiceworks.com
16
4
April 16, 2013
Select Replace and convert from int to string
here is the select from table originally. accessright 0 1 2 3 the data i want become: 0=Deny 1=Read 2=Write 3=Admin the records will shows like this: accessright Deny Read Write Admin SELECT CASE WHEN b.RightType IN ('0') Then 'Deny'; CASE WHEN b.RightType IN ('1') Then 'Read'; CASE WHEN ... More on forums.sqlteam.com
๐ŸŒ forums.sqlteam.com
0
0
March 29, 2017
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
๐ŸŒ
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
Msg 245, Level 16, State 1, Line 3 Conversion failed when converting the varchar value ' is not a string.' to data type int. In order to evaluate the expression @notastring + ' is not a string.', SQL Server needs to follow the rules of data type precedence to complete the implicit conversion before the result of the expression can be calculated.
๐ŸŒ
MSSQLTips
mssqltips.com โ€บ home โ€บ sql convert int to string
SQL Convert INT to String
May 28, 2025 - In this article, we will look at various ways in SQL Server to convert int to string include the SQL CONVERT function, SQL CAST function and SQL CONCAT function.
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ func_sqlserver_convert.asp
SQL Server CONVERT() Function
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... The CONVERT() function converts a value (of any type) into a specified datatype. Tip: Also look at the CAST() ...
Find elsewhere
๐ŸŒ
Oreate AI
oreateai.com โ€บ blog โ€บ bridging-worlds-seamlessly-converting-integers-to-strings-in-sql โ€บ 97ab92062728bca7e66c07ddaf04f196
Bridging Worlds: Seamlessly Converting Integers to Strings in SQL - Oreate AI Blog
February 17, 2026 - It's very similar to CAST, but ... int-to-string conversion, it's often used in a similar way. The basic syntax is CONVERT(data_type, expression)....
๐ŸŒ
SQLTeam
forums.sqlteam.com โ€บ transact-sql
Select Replace and convert from int to string - Transact-SQL - SQLTeam.com Forums
March 29, 2017 - here is the select from table originally. accessright 0 1 2 3 the data i want become: 0=Deny 1=Read 2=Write 3=Admin the records will shows like this: accessright Deny Read Write Admin SELECT CASE WHEN b.RightType IN ('0') Then 'Deny'; CASE WHEN b.RightType IN ('1') Then 'Read'; CASE WHEN b.RightType IN ('2') Then 'Write'; CASE WHEN b.RightType IN ('3') Then 'Admin'; ELSE b.RightType END from [dbo].[_EPOS_UserRoleRights] b with (nolock) error message shows: Conversion fa...
๐ŸŒ
Reddit
reddit.com โ€บ r/sql โ€บ when using a case, can you convert int to varchar?
r/SQL on Reddit: When using a case, can you convert int to varchar?
June 5, 2019 -

I have a case I need to show a string but the field I am looking at is int. Is there way to show the string Value when intfield > 0?

CASE
	WHEN [table].[intfield] > 0 THEN 'Value'
	ELSE [poop].[pee]
END AS "Bathroom"
Top answer
1 of 3
23

Consider an INT in SQL Server. It can be one of three values:

  • NULL
  • 0
  • Not 0

So if you're casting/converting an empty string, which you are assuming is a number, then 0 is the most logical value. It allows for a distinction between NULL and 0.

SELECT CAST(NULL AS INT) -- NULL
SELECT CAST('' AS INT)   -- 0
SELECT CAST('42' AS INT) -- 42

I'd say that's logical.

If you did:

SELECT CAST('abc' AS INT)

You'd get:

Conversion failed when converting the varchar value 'abc' to data type int.

If you do wish to handle empty strings as NULL use NULLIF as Bogdan suggests in his answer:

DECLARE @val VARCHAR(2) = ''

SELECT CAST(NULLIF(@val,'') AS INT)  -- produces NULL

NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression.

Finally, if your columns are storing INT values, then consider changing its data type to INT if you can.

2 of 3
0

As you probably know NULL is a marker that indicates that a data value does not exist. And '' is a value, empty but value.

So MS SQL cast (or converts) empty value into 0 by default. To overcome this and show it as NULL you can use NULLIF

Simple example:

SELECT  int_as_varchars as actual,
        cast(NULLIF(int_as_varchars,'') as int) as with_nullif,
        cast(int_as_varchars as int) as just_cast
FROM (VALUES
('1'),
(''),
(NULL),
('0')
) as t(int_as_varchars)

Output:

actual  with_nullif just_cast
1       1           1
        NULL        0
NULL    NULL        NULL
0       0           0

As you see NULLIF in that case will help you to get NULL instead of 0.

๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ blogs โ€บ convert-integer-to-string-in-sql-server
Convert Integer to String in SQL Server
March 14, 2023 - An integer can be converted to a SQL server string using built-in functions like CAST, CONVERT, and STR.
๐ŸŒ
Steve Stedman
stevestedman.com โ€บ 2024 โ€บ 06 โ€บ converting-text-to-integer-in-sql-server
SQL Convert Text To Integer
November 17, 2024 - Converting data types is a common task in SQL Server, especially when dealing with data imports or migrations where data might not be in the desired format. One frequent requirement is converting text data to integer data types.
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_datatypes.asp
SQL Data Types for MySQL, SQL Server, and MS Access
The data type is a guideline for SQL to understand what type of data is expected inside of each column, and it also identifies how SQL will interact with the stored data. Always check the documentation! Data types might have different names in different databases. And even if the name is the same, the size and other details may be different! In MySQL there are three main data types: String, Numeric, and Date and Time.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ convert-int-to-varchar-sql
Convert INT to VARCHAR SQL - GeeksforGeeks
July 23, 2025 - One of the basic SQL operations used to convert numerical data into string format is the conversion of INT to VARCHAR. we have come across a number of way, including CAST, CONVERT, CONCAT, and FORMAT, all of which provide different ways to accomplish the conversion.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ sql-query-to-convert-varchar-to-int
SQL Query to Convert VARCHAR to INT - GeeksforGeeks
target_type โ€“ Target data type to which the value will be converted. e.g. INT, BIT, SQL_VARIANT, etc. length โ€“ Optional parameter that specifies the length of the target_type, default length is 30. If we have a column storing numeric data as strings and you want to convert the value '1234' to an INT, use the following query:
Published ย  July 23, 2025
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ function.date.php
PHP: date - Manual
To format dates in other languages, IntlDateFormatter::format() can be used instead of date(). ... To generate a timestamp from a string representation of the date, you may be able to use strtotime(). Additionally, some databases have functions to convert their date formats into timestamps (such as MySQL's ยป UNIX_TIMESTAMP function).
๐ŸŒ
Table Convert
tableconvert.com โ€บ home โ€บ convert excel to insert sql online
Convert Excel to Insert SQL Online - Table Convert
July 28, 2025 - Supports multiple database dialects (MySQL, PostgreSQL, SQLite, SQL Server, Oracle), automatically handles data type mapping, character escaping, and primary key constraints. Ensures generated SQL code can be executed directly. Extract tables from any website with one click. Convert to 30+ formats including Excel, CSV, JSON instantly - no copy-pasting required.