Q:

SQL Server Like Match and Exclude

I have a table (DataTable) with a column that contains data like this in one of the columns:
DataColumn    
ABCD
ABCE
ABCF
ABXY

I have another table (MatchTable) that includes a pattern column and value column that can be used to get matching rows from the DataTable based on the match:
MatchPattern   Value
AB%            1

I want to exclude the ABCE row from the result set and I don't want to have rows in my match table for ABCD%, ABCF%, etc as the ABCE is the exception to the rule.  My pattern could be AB[^C]%, but that will exclude all ABCs and I only want to exclude ABCE.  The sql for this is:
SELECT D.DataColumn, P.Value
FROM MatchTable M
INNER JOIN DataTable D ON D.DataColumn LIKE M.Pattern

I know I could add another column to my matching table called something like ExcludePattern with the following:
MatchPattern   ExcludePattern Value
AB%            ABCE           1

SELECT D.DataColumn, P.Value
FROM MatchTable M
INNER JOIN DataTable D ON D.DataColumn LIKE M.MatchPattern
                          AND D.DataColumn NOT LIKE M.ExcludePattern

I am wondering if there is a way to create a like pattern that will match all ABs except for ABCE in one pattern?  Basically, can this be done using the built-in like or do I have to implement regex?

A:

There's definitely no way to do what you want in a single LIKE pattern.

