I need to Concatenate a Varchar
and int
in T-SQL , !
In the earlier version of SQL Server, we usually use CONVERT function to convert int into varchar and then concatenate it. Given below is the script. Solution 2: In this solution, we will use CONCAT function (a newly shipped function in SQL Server 2012) to convert int into varchar then concatenate it.
To concatenate we can use + sign but this works only with String values. So if we have any Integer value/s we have to convert them to String first. We can use Cast or Convert function to convert Integer value to string.
Solution. TSQL provides 2 ways to concatenate data, the + sign and the new CONCAT() function. This tip will cover the differences in the two, so you can achieve the expected behavior in your code. The way most us are used to concatenating data together is using the + sign.
SELECT ('VarValue' + CAST(32 AS VARCHAR))
varcharName + cast(intName as varchar) as full_name
Should do it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With