문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top