insert into #test values ('abc','efg','sweet') insert into #test values ('abc','hik','sour') insert into #test values ('xyz','efg','salty') insert into #test values ('lmn','efg','neat') insert into #test values ('fju','asw','write') insert into #test values ('fnmjju','assssw','cc')
select * from #test where col1 in (select col1 from #test1) union all select * from #test where col2 in (select col1 from #test1) and not exists (select * from #test where col1 in (select col1 from #test1))
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy.
That will get rows if it matches with col1 or col2. Mine gets rows for matches on col1 and if there are none gets rows that match on col2.
Not really clear what is wanted.
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy.
That will get rows if it matches with col1 or col2. Mine gets rows for matches on col1 and if there are none gets rows that match on col2.
Not really clear what is wanted.
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy.
As usual, you are right, Nigel. On reading the original post again, I think OP is asking for the latter of the two.