SQL不像语句

NET*_*ion 4 sql t-sql

如何从sys.tables中选择表,其中表名不包含特殊字(传入参数).

我想选择所有包含单词'customer'的表,而不是那些以'old'结尾的表.

TableName在DB中

customer1
customer2
customer3
customerold1
customerold2

输出通缉

customer1
customer2
customer3

Mic*_*tta 15

SELECT * FROM sys.tables
    WHERE TableName LIKE '%customer%'
      AND TableName NOT LIKE '%old' -- note the lack of trailing '%'
Run Code Online (Sandbox Code Playgroud)

喜欢(Transact-SQL)