I think you need something like this-- prepare test datadeclare @EFT1 table (num varchar(100))insert @eft1select 'EFT1938364' union allselect '33457489' union allselect '293723628' union allselect 'EFT182720' union allselect 'EFT6728292' union allselect '338272611' union allselect '293837333'declare @EFT2 table (num varchar(100))insert @eft2select 'EFT1938364' union allselect '0033457489' union allselect '000293723628' union allselect 'EFT182720' union allselect 'EFT6728292' union allselect '338272611' union allselect '293837333'-- do the magicSELECT eft1.*, eft2.*FROM @eft1 eft1INNER JOIN @eft2 eft2 ON SUBSTRING(eft2.num, PATINDEX('%[^0]%', eft2.num), 100) = SUBSTRING(eft1.num, PATINDEX('%[^0]%', eft1.num), 100)
Peter LarssonHelsingborg, Sweden