This script will remove the database tuning advisor tables in the MSDB database on a SQL Server.
USE [msdb]
GO
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'dtproperties')
DROP TABLE dtproperties;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports')
DROP TABLE DTA_reports;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_sessions')
DROP TABLE DTA_sessions;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_stats_internal')
DROP TABLE DTA_stats_internal;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_tuning_log')
DROP TABLE DTA_tuning_log;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_output')
DROP TABLE DTA_output;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_progress')
DROP TABLE DTA_progress;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_indexcolumn')
DROP TABLE DTA_reports_indexcolumn;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_partitionscheme')
DROP TABLE DTA_reports_partitionscheme;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_querycolumn')
DROP TABLE DTA_reports_querycolumn;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_querydatabase')
DROP TABLE DTA_reports_querydatabase;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_queryindex')
DROP TABLE DTA_reports_queryindex;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_querytable')
DROP TABLE DTA_reports_querytable;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_tableview')
DROP TABLE DTA_reports_tableview;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_tuninglog')
DROP TABLE DTA_tuninglog;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_tuningresults')
DROP TABLE DTA_tuningresults;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_tuningresults_part')
DROP TABLE DTA_tuningresults_part;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_column')
DROP TABLE DTA_reports_column;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_index')
DROP TABLE DTA_reports_index;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_partitionfunction')
DROP TABLE DTA_reports_partitionfunction;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_query')
DROP TABLE DTA_reports_query;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_table')
DROP TABLE DTA_reports_table;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_reports_database')
DROP TABLE DTA_reports_database;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'DTA_input')
DROP TABLE DTA_input;
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_wkld_analysis_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_wkld_analysis_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_wkld_analysis_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_wkld_analysis_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_view_table_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_view_table_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_view_table_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_view_table_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_update_tuninglog_errorfrequency')
DROP PROCEDURE [dbo].[sp_DTA_update_tuninglog_errorfrequency]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_update_session')
DROP PROCEDURE [dbo].[sp_DTA_update_session]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_table_access_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_table_access_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_table_access_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_table_access_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_start_xmlprefix')
DROP PROCEDURE [dbo].[sp_DTA_start_xmlprefix]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_set_tuningresults_part')
DROP PROCEDURE [dbo].[sp_DTA_set_tuningresults_part]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_set_tuningresults')
DROP PROCEDURE [dbo].[sp_DTA_set_tuningresults]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_set_tuninglogtablename')
DROP PROCEDURE [dbo].[sp_DTA_set_tuninglogtablename]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_set_progressinformation')
DROP PROCEDURE [dbo].[sp_DTA_set_progressinformation]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_set_outputinformation')
DROP PROCEDURE [dbo].[sp_DTA_set_outputinformation]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_set_interactivestatus')
DROP PROCEDURE [dbo].[sp_DTA_set_interactivestatus]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_indexrelations_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_query_indexrelations_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_indexrelations_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_query_indexrelations_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_detail_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_query_detail_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_detail_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_query_detail_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_costrange_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_query_costrange_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_costrange_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_query_costrange_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_cost_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_query_cost_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_query_cost_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_query_cost_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_tableview')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_tableview]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_table')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_table]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_querytable')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_querytable]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_queryindex')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_queryindex]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_querydatabase')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_querydatabase]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_querycolumn')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_querycolumn]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_query')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_query]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_partitionscheme')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_partitionscheme]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_partitionfunction')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_partitionfunction]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_indexcolumn')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_indexcolumn]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_index')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_index]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_database')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_database]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_reports_column')
DROP PROCEDURE [dbo].[sp_DTA_insert_reports_column]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_progressinformation')
DROP PROCEDURE [dbo].[sp_DTA_insert_progressinformation]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_insert_DTA_tuninglog')
DROP PROCEDURE [dbo].[sp_DTA_insert_DTA_tuninglog]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_index_usage_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_index_usage_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_index_usage_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_index_usage_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_index_recommended_detail_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_index_recommended_detail_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_index_detail_recommended_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_index_detail_recommended_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_index_detail_current_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_index_detail_current_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_index_current_detail_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_index_current_detail_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_help_session')
DROP PROCEDURE [dbo].[sp_DTA_help_session]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_tuningoptions')
DROP PROCEDURE [dbo].[sp_DTA_get_tuningoptions]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_tuninglog')
DROP PROCEDURE [dbo].[sp_DTA_get_tuninglog]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_tableids')
DROP PROCEDURE [dbo].[sp_DTA_get_tableids]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_session_tuning_results')
DROP PROCEDURE [dbo].[sp_DTA_get_session_tuning_results]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_session_report')
DROP PROCEDURE [dbo].[sp_DTA_get_session_report]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_pstableids')
DROP PROCEDURE [dbo].[sp_DTA_get_pstableids]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_pftableids')
DROP PROCEDURE [dbo].[sp_DTA_get_pftableids]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_interactivestatus')
DROP PROCEDURE [dbo].[sp_DTA_get_interactivestatus]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_indexableids')
DROP PROCEDURE [dbo].[sp_DTA_get_indexableids]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_databasetableids')
DROP PROCEDURE [dbo].[sp_DTA_get_databasetableids]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_get_columntableids')
DROP PROCEDURE [dbo].[sp_DTA_get_columntableids]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_event_weight_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_event_weight_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_event_weight_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_event_weight_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_end_xmlprefix')
DROP PROCEDURE [dbo].[sp_DTA_end_xmlprefix]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_delete_session')
DROP PROCEDURE [dbo].[sp_DTA_delete_session]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_database_access_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_database_access_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_database_access_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_database_access_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_column_access_helper_xml')
DROP PROCEDURE [dbo].[sp_DTA_column_access_helper_xml]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_column_access_helper_relational')
DROP PROCEDURE [dbo].[sp_DTA_column_access_helper_relational]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_cleanup_hypothetical_metadata')
DROP PROCEDURE [dbo].[sp_DTA_cleanup_hypothetical_metadata]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_check_permission')
DROP PROCEDURE [dbo].[sp_DTA_check_permission]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'sp_DTA_add_session')
DROP PROCEDURE [dbo].[sp_DTA_add_session]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE name = 'fn_DTA_unquote_dbname')
DROP FUNCTION [dbo].[fn_DTA_unquote_dbname]
Leave a Reply