SQL - Generate Scripts to Drop Tables/Views
You can use the commands below to create SQL commands which will drop tables/views. the were clause can be used to limit which tables/views are included in the statement.
Drop Tables
SELECT 'DROP TABLE [' + TABLE_NAME + ']'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME NOT LIKE 'CRM%'
AND TABLE_TYPE = 'BASE TABLE'
Drop Views
SELECT 'DROP VIEW [' + TABLE_NAME + ']'
FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME NOT LIKE 'CRM%'
Comments
Post a Comment