insert @t3
select distinct t1nodekey from @t1
where exists (select t2nodekey from @t2 where t1nodekey like t2nodekey+'%')
UNION
select distinct t2nodekey from @t2
where exists (select t1nodekey from @t1 where t2nodekey like t1nodekey+'%')
But because of huge data in these tables it is causing bad performance. Can anybody suggest any better solution to accomplish this. I'm using SQLserver 2005. Thanks in advance, Su