I am trying to add the 2 columns both varchar(2) and need to sum the 2 columns like 5+3=8 but its not adding them its concatenating them, I have tried so many conversion but not working because of conversion to INT,
CAST(COnvert(varchar,A.E1CODE) AS INT) + CAST(COnvert(varchar,AJOB_Code) AS INT)
from your table
connversion failed when converting the varchar value 'N' to data type int.
what is the best way to add (sum)these 2 columns in the SELECT Satement? Probabaly something simple I am missing?
Thanks.
Pasi
create table #pasi_oracle_migration(E1code varchar(2), job_code varchar(2))
insert into #pasi_oracle_migration
select '5', '02' union
select 'N', '00'
select E1code, job_code,
case
when ISNUMERIC(E1code) = 1
then cast(CAST(E1CODE AS INT) + CAST(job_code AS INT) as varchar(150))
else E1code + job_code
end as bootleg
from #pasi_oracle_migration
drop table #pasi_oracle_migration