Append String To Int [closed]
-
14-03-2021 - |
Pregunta
I need to add a %
sign to a calculation I'm doing in MS SQL Server. This is the syntax I am using
Cast(Round(Coalesce(totalsaleamt,0) * 100,0) As Int) + '%'
but I get the error
Conversion failed when converting the varchar value '%' to data type int
What is the proper way to make this concatenation?
Solución
Try with something like:
Convert(Varchar(100),Cast(Round(Coalesce(totalsaleamt,0) * 100,0) As Int)) + '%'
That will convert your INT into a varchar and it will then be possible to add the % sign.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a dba.stackexchange