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%'