3
如何选择从哪里SYS.TABLES表名不containt特字(其中传递参数)表。SQL不喜欢声明
我想选择其中的包含谁与名“老” 结尾词“顾客”,但不是那些所有表。
表名在DB
customer1表
的customer2
customer3
customerold1
customerold2
输出求购
customer1表
的customer2
customer3
如何选择从哪里SYS.TABLES表名不containt特字(其中传递参数)表。SQL不喜欢声明
我想选择其中的包含谁与名“老” 结尾词“顾客”,但不是那些所有表。
表名在DB
customer1表
的customer2
customer3
customerold1
customerold2
输出求购
customer1表
的customer2
customer3
SELECT * FROM sys.tables
WHERE TableName LIKE '%customer%'
AND TableName NOT LIKE '%old' -- note the lack of trailing '%'
假设你有你的特殊字的参数,你可以这样做:
WHERE TableName LIKE @specialWord + '%'
AND TableName NOT LIKE '%' + @specialWord + '%old%'