Converting Integer to String in SQL Server
Hello to everyone,
In this article, I will try to give information about how to convert an Integer value to a String value in SQL Server.
Conversion between types is the most used structures in SQL Server. You must have used it while coding.
If you didn’t use it, you will now.
You can easily do this using the code below.
DECLARE @i int
SET @i=65536
--Method 1 : Use CAST function
SELECT CAST(@i as varchar(10))
--Method 2 : Use CONVERT function
SELECT CONVERT(varchar(10),@i)
--Method 3 : Use STR function
SELECT LTRIM(STR(@i,10))
When you run the above code, you will see the following result. You can revise and use it according to your own codes.
As you can see, Integer value has been converted to String value.
Good luck to everyone in business and life.