DROP TABLE and DROP VIEW Using Certain Criteria

SELECT
'
DROP TABLE [' + TABLE_SCHEMA + '].'+ TABLE_NAME
from INFORMATION_SCHEMA.TABLES where table_schema='AEN\reina.martiana'


SELECT
'
DROP TABLE [' + TABLE_SCHEMA + '].'+ TABLE_NAME
from INFORMATION_SCHEMA.TABLES where table_schema='DBO' AND NOT ISNUMERIC(LEFT(TABLE_NAME,1))=1
AND TABLE_TYPE='BASE TABLE'




SELECT
'
DROP ' + CASE WHEN TABLE_TYPE='BASE TABLE ' THEN 'TABLE'
         ELSE 'VIEW ' END + '[' + TABLE_SCHEMA + '].'+ '[' + TABLE_NAME + '] '

FROM INFORMATION_SCHEMA.TABLES
where table_schema='DBO'
AND
(TABLE_NAME LIKE 'x-%'
 or
 TABLE_NAME LIKE 'TABLE%'
 OR
 TABLE_NAME LIKE 'VIEW%'
 )

 ORDER BY TABLE_NAME



SELECT
'
DROP ' + CASE WHEN TABLE_TYPE='BASE TABLE ' THEN 'TABLE'
         ELSE 'VIEW ' END + '[' + TABLE_SCHEMA + '].'+ '[' + TABLE_NAME + '] '

FROM INFORMATION_SCHEMA.TABLES
where table_schema='DBO'
AND
(ISNUMERIC(LEFT(TABLE_NAME,2))=1)
 ORDER BY TABLE_NAME

 SELECT
'
DROP ' + CASE WHEN TABLE_TYPE='BASE TABLE ' THEN 'TABLE '
         ELSE 'VIEW ' END + '[' + TABLE_SCHEMA + '].'+ '[' + TABLE_NAME + '] '

FROM INFORMATION_SCHEMA.TABLES
where table_schema='DBO'
AND
(table_name like '%backup_tbl_%')
 ORDER BY TABLE_NAME

Mudik Lebaran 1439H 2018