Portal Home > Knowledgebase > cPanel > Delete all tables for a specific client


Delete all tables for a specific client




Open SQL server manager.

Find DB tables.

Create new query (top left).

Enter following (excluding quotes):

"
 use [DSNNAME];
 
 SELECT distinct TABLE_NAME
   FROM INFORMATION_SCHEMA.COLUMNS
  WHERE TABLE_NAME like 'DBPREFIX_%';
select 'drop table [' + TABLE_SCHEMA + '].[' + TABLE_NAME + ']'
from INFORMATION_SCHEMA.TABLES
where TABLE_NAME like 'DBPREFIX_%'
"

*Notes:

    replace DSNNAME with proper database ... CMS2010, CMS2011, CMS2012, etc
    replace DBPREFIX with CLIENT_CODE
    script above will generate all the required DELETE statements

Click Execute.
Click on "No column name".
All columns below should be selected.
Copy selected.
Make new query.
Paste.
Execute.

The tables will now be dropped/deleted.

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article