SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Where mystring not like (list of items)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

DaveBF
Yak Posting Veteran

88 Posts

Posted - 08/04/2011 :  09:21:15  Show Profile  Reply with Quote
If I have:
...where myString not like '%abc' and myString not like 'xyz%' and myString not like '%aaa' and myString not like 'ert%'...

is there a way to shorten this, using "NOT IN" and somehow just list all the strings that I don't want it to match?

Dave

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 08/04/2011 :  09:29:43  Show Profile  Reply with Quote
you can add the search strings onto a temporary table and use it in join on condition like

ON t1.Col1 NOT LIKE '%' + temp.Pattern

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000