How to delete hosts

1. Obtain the id of the hosts (HOSTID) you want to delete, querying on T04STATHOSTINFO selecting by HOSTNAME.

 SELECT [HOSTID] FROM [T04_Dashboards].[dbo].[T04STATHOSTINFO] WHERE HOSTNAME='hostname1' OR HOSTNAME='hostname2'... 


2. Obtain from T04STATMEASUREMENTS all MEASUREMENTID corresponding to the HOSTIDs obtained in the step 1.

 SELECT [MEASUREMENTID] FROM [T04_Dashboards].[dbo].[T04STATMEASUREMENTS] WHERE HOSTID IN (SELECT [HOSTID] FROM [T04_Dashboards].[dbo].[T04STATHOSTINFO] WHERE HOSTNAME='hostname1' OR HOSTNAME='hostname2'...) 


3. Delete from T04STATSTOREDCHARTCONTEXTINFO and T04STATSTOREDVALUES entries corresponding to the MEASUREMENTIDs obtained in step 2.

 DELETE FROM [T04_Dashboards].[dbo].[T04STATSTOREDCHARTCONTEXTINFO] WHERE MEASUREMENTID IN (SELECT [MEASUREMENTID] FROM [T04_Dashboards].[dbo].[T04STATMEASUREMENTS] WHERE HOSTID IN (SELECT [HOSTID] FROM [T04_Dashboards].[dbo].[T04STATHOSTINFO] WHERE HOSTNAME='hostname1' OR HOSTNAME='hostname2'...)) 

 

 DELETE FROM [T04_Dashboards].[dbo].[T04STATSTOREDVALUES] WHERE MEASUREMENTID IN (SELECT [MEASUREMENTID] FROM [T04_Dashboards].[dbo].[T04STATMEASUREMENTS] WHERE HOSTID IN (SELECT [HOSTID] FROM [T04_Dashboards].[dbo].[T04STATHOSTINFO] WHERE HOSTNAME='hostname1' OR HOSTNAME='hostname2'...)) 


4. Delete from T04STATMEASUREMENTS all the entries corresponding to the hosts obtained in the step 1.

 DELETE FROM [T04_Dashboards].[dbo].[T04STATMEASUREMENTS] WHERE HOSTID IN (SELECT [HOSTID] FROM [T04_Dashboards].[dbo].[T04STATHOSTINFO] WHERE HOSTNAME='hostname1' OR HOSTNAME='hostname2'...) 


5. Delete from T04STATHOSTINFO all the entries corresponding to the hosts obtained in the step 1.

 DELETE FROM [T04_Dashboards].[dbo].[T04STATHOSTINFO] WHERE HOSTNAME='hostname1' OR HOSTNAME='hostname2'... 


That's because many of the attributes of the tables are references in other tables and because of that you can't delete it with only a DELETE query, you must follow these steps.


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: October 18, 2018