I have 2 tables and each table has say 1 column with thousands of rows.
create table #t1 (id varchar (2) ) create table #t2 (id varchar (2) ) insert into #t1 values('01') insert into #t1 values('2') insert into #t2 values('1') insert into #t2 values('02') select * from #t1 as a inner join #t2 as b on cast(a.id as integer) = cast(b.id as integer) select * from #t1 as a inner join #t2 as b on a.id = b.id OR '0' + a.id = b.id OR a.id = '0' + b.id
both columns could have values in different format but they are same in real world. So in this example, 1 is equal to 01. To get that result, i have 2 approaches mentioned above. I need a validation of my assumption that approach without casting is the better one. I can't update data in table to avoid concatenation or casting.