Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Yak Posting Veteran

89 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?


Very Important crosS Applying yaK Herder

52326 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

Go to Top of Page
  Previous Topic Topic Next 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.03 seconds. Powered By: Snitz Forums 2000