I came across this scenario wherein I tried to concatenate a Char data type variable and a string but the results were pretty surprising.
declare @Var char(10) = 546875.5
set @Var = @Var + '100'
select @Var
Output: 546875.5
I tried to increase the size of the variable , but still the same result.
declare @Var char(100) = 546875.5
set @Var = @Var + '100'
select @Var
Output : 546875.5
When I reversed the concatenation, strings did concatenate :
declare @Var char(10) = 546875.5
set @Var = '100' + @Var
select @Var
Output: 100546875.
Can anyone please help me solve this mystery.
Please note:: I understand that I can convert both before concatenating and that will serve the purpose. But I am not sure why this is not working.
TIA !!
