Here is the sql statement to generate the scripts to drop hypothetical indexes that were generated by SQL Database Engine Tunning Advisor (DTA).
SELECT 'DROP INDEX [' + s.[name] + '] ON [' + object_name(s.[object_id]) +'] '
FROM sys.stats AS s
INNER JOIN sys.indexes AS i
ON s.name=i.name
WHERE i.is_hypothetical=1 and s.[name] LIKE '_dta_ind%'
SELECT 'DROP STATISTICS [' + object_name(s.[object_id]) + '].[' + s.[name] + '] '
FROM sys.stats AS s
WHERE s.name like '_dta_stat%'
Subscribe to:
Post Comments (Atom)
Easy and simple, thanks!
ReplyDelete