How, How I can get the expected result. I want to compare #A with #B and get the descrepancy in the result. Key column is Ename in #A and Ename1 in #B. When we need to remove "hyphen and after the hyphen number" from Ename then join with Ename1 of #B. Please help.
create table #A (Ename char(10), ED char(4), EE char(4), EG char(4))
insert into #A ('214129-03','03','CAS','GRP')
insert into #A ('214130-04','04','PER','GRP')
insert into #A ('214132-06','06','CAS','GRP')
create table #B (Ename1 char(10), ED1 char(4), EE1 char(4), EG1 char(4))
insert into #B ('214129','03','CAS','GRP')
insert into #B ('214130','04','CAS','GRP')
insert into #B ('214132','06','TAS','GRP')
--Expected result
Ename ED EE EG Ename1 ED1 EE EG
214130-04 04 PER GRP 214130 04 CAS GRP
214132-06 04 CAS GRP 214132 06 TAS GRP