I tried to list all tables in a MS-SQL Server Database that table name start with “_” character. So I used this query at first glance:
SELECT name
FROM sys.tables
WHERE name LIKE '_%'
But this query returned all tables. I realized that MS-SQL Server is not recognizing the underscore as a wildcard character. Then I tried escaping the underscore by using brackets. Here’s the corrected query:
SELECT name
FROM sys.tables
WHERE name LIKE '[_]%'
This command lists all tables that start with an underscore.