25112
asked on
keep only certain schema tables from a restore
there are 10 schemas in a backup file.. after the restore, though, we want to only the tables from 2 schemas..
after restore, what could be a simple script to drop all the tables that dont belong to those 2 (LTW & PTO) schemas?
thanks
after restore, what could be a simple script to drop all the tables that dont belong to those 2 (LTW & PTO) schemas?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
--find all tables in schema
select so.name --*
from sys.objects so inner join sys.schemas ss on so.schema_id = ss.schema_id
where ss.name not in('LTW','PTO')
and so.type = 'U' -- user table
then loop trhough the set and create/execute a DROP TABLE command.