Delete all tables in SQL Server database except few
You can use dynamic query to DROP
the required tables:
DECLARE @ExecSQL AS NVARCHAR (MAX) = '';
SELECT @ExecSQL = @ExecSQL +
'DROP TABLE ' + QUOTENAME(S.name) + '.' + QUOTENAME(T.name) + '; '
FROM sys.tables T
JOIN sys.schemas S ON S.schema_id = T.schema_id
WHERE T.name LIKE '%DynamicSurgery'
--PRINT @ExecSQL
EXEC (@ExecSQL)