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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Where mystring not like (list of items)

Author  Topic 

DaveBF
Yak Posting Veteran

89 Posts

Posted - 2011-08-04 : 09:21:15
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

52326 Posts

Posted - 2011-08-04 : 09:29:43
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
   

- Advertisement -