Remove Databases from MonitoringDB

mschiermschier Posts: 14 New member
edited August 25, 2016 5:48AM in SQL Monitor Previous Versions
Hi,

we have a daily job that restores every night some databases to verify that the backup is valid.
These were restored as <DatabaseName+UUID>.

I want to delete these Databases after a time period from the redgate database.
How can I do it?

Regards
Michael

Comments

  • Hi mschier,

    If you run the below script, this will remove the database from the SQL Repository. The databases would also be removed after all the data is removed via the purge settings. Please let me know if you have any further problems with this.

    DELETE db FROM data.Cluster_SqlServer_Database_Keys db
    INNER JOIN data.Cluster_SqlServer_Keys ss
    ON ss.id = db.ParentId
    WHERE db._Name = 'YourDatabaseName'-- Database Name
    -- SQL instance Name if it is a standalone instance on a cluster node it is "nodenameinstanceName"
    --The instance name is blank if it is the default instance "nodename"
    AND ss._Name = 'YourInstanceName'
    --Standalone machines are entered/named at the cluster level and the machine level is blank
    --Clusters are named here with their nodes in data.Cluster_Machine_Keys
    AND ss.ParentId IN (SELECT Id FROM data.Cluster_Keys
    WHERE _Name = 'YourMachineOrClusterName');
    Kind regards,
    Dan Bainbridge
    Product Support Engineer | Redgate Software
Sign In or Register to comment.