Clean up master database

  • Hi,

    I ran a script to install a database and did not notice that it is going to put them all on the master database. Now I have a messy master database with some 20 tables there. I cannot delete them as they have dependencies. I can probably go drop constraint one by one and try again, but I was just wondering if there is a better and smarter method to do just that. 

    thank

  • mohandesan 32791 - Tuesday, July 10, 2018 1:46 PM

    Hi,

    I ran a script to install a database and did not notice that it is going to put them all on the master database. Now I have a messy master database with some 20 tables there. I cannot delete them as they have dependencies. I can probably go drop constraint one by one and try again, but I was just wondering if there is a better and smarter method to do just that. 

    thank

    One fairly easy way - 
    Check your script options (tools - options - SQL Server object explorer - scripting) and make sure to enable Generate Script for Dependent objects
    Then open object explorer details for master database
    Select the tables you want  to delete and then right click and select Script table as drop to...(file, query window) and it will generate the script to drop the dependent objects and the table.

    It's faster to do that than it is to type how to do it.

    Sue

  • Wonderful solution Sue. Thank you.

  • Datazita - Tuesday, July 10, 2018 5:21 PM

    Wonderful solution Sue. Thank you.

    Your very welcome...thanks for the feedback. Object explorer details view is good for selecting different things like that - with Ctrl select or shift select.

    Sue

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply