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.

Converting Integer to String in SQL Server

As you can see, Integer value has been converted to String value.

Good luck to everyone in business and life.

391 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!