SELECT 'EXEC
(''DROP STATISTICS [' + su.name + '].[' + so.name + '].[' + si.name + ']'')'
FROM sysindexes
si
JOIN sysobjects
so
ON si.id = so.id
JOIN sysusers
su
on su.uid = so.uid
WHERE INDEXPROPERTY(si.id,si.name, 'IsStatistics') = 1
--AND si.name not like
'_WA_Sys%'
AND OBJECTPROPERTY(so.id, 'IsUserTable') = 1
ORDER BY
so.name, si.name
No comments:
Post a Comment