June 25, 2012 at 7:06 am
Hi
I am trying to find a logic to do this.
I have to create package in SSIS,for source I want use SQLcommand from variable.But the case is I want to select some records from table 1 where column1 is like any record from table 2
EX:
select * from table1 where col1 IN (select col1 from table 2) and col2='xx' and col3-'yy'
but I have to filter it by LIKE
Ex:
select * from table1 where col1 LIKE %abc%'
in above statement I want to give 50 keyword's to check against col1.
those 50 keywords are in another table.If I use IN operator it doesn't do like that is there any other way I can do this.
Let me know if question is not clear.
Thanks a lot for any help.
June 25, 2012 at 7:16 am
Instead of doing it in the Where clause, do it with a Join.
select *
from Table1
inner join Table2
on Table1.Col1 like '%' + Table2.ColA + '%'
where Table1.Col2 = 'xx';
Like that.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 25, 2012 at 7:25 am
Wow Great.really liked it.
Thanks.
June 26, 2012 at 6:39 am
You're welcome.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply