Find all tables where column like:
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName'
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%SubId%'
ORDER BY TableName
,ColumnName;
Find all tables where table name like:
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName'
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE t.name LIKE '%tbl%'
ORDER BY TableName
,ColumnName;
Find all tables in a specific schema:
SELECT t.name
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
ON t.[schema_id] = s.[schema_id]
WHERE s.name = N'cmc';
Once you have the tables you need to delete you can just write delete statements for each one. Or you could use something like the below:
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName',
'drop table ' + t.name
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE t.name LIKE '%tbl%'
ORDER BY TableName
,ColumnName;
EDIT
Below a select with a little more detail on the where clause:
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName'
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE
t.name LIKE 'tbl%' -- where the table name starts with the letters 'tbl'
OR t.name LIKE 'tbl%123%' -- where the table name starts with the letters 'tbl' and has the numbers '123' in the table name
OR c.name LIKE '%colName%' -- where a column has a name that contains the letters 'colName'
ORDER BY TableName
,ColumnName;