2014-11-28

如何刪除一個 TABLE 下的所有統計資料

個人筆記:如何刪除一個 TABLE 下的所有統計資料:

SELECT 'DROP STATISTICS [' + T3.name + '].[' + T1.name + '].[' + T2.name + '];'
  FROM SYS.objects AS T1
     , SYS.stats AS T2
     , sys.schemas AS T3
 WHERE T1.type = 'U'
   AND T1.name = 'CustContacts'
   AND T2.object_id = T1.object_id
   AND T3.schema_id = T1.schema_id
   AND T3.name = 'acc'
[DROP STATISTICS]

沒有留言: