

The STR() function has the following syntax. And the character value is right-justified, with a specified length and decimal precision. STR() is another function in SQL Server that accepts number values and returns them as a varchar expression.

Int to varchar using Convert() Converting to string/varchar using STR() And the query will return the following result.

After this, we are using the Cast() function to convert the variable to the varchar data type of length 10. So, in the above example, we have declared a variable of integer data type and assigned a value to the variable. The Cast() function accepts two values, the first is the expression whose data type a user wants to change, and the second is the resulting data type that a user wants. The Cast() in SQL Server, is a function that converts a value of one data type to another. Converting int to string/varchar using Cast() And in this section, we will discuss all the methods with the help of an example. In SQL Server, there are 3 different ways through which we can convert an expression of integer data type to varchar. SQL Server Convert Datetime/date to int SQL Server Convert int to string/varchar
