_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 碁煙れ(2000覯)

Contents

1 碁煙 ク 磯ジ 碁煙 譟郁覈 ろ襴渚


1 碁煙 ク 磯ジ 碁煙 譟郁覈 ろ襴渚 #

Use 一危磯伎る -- 蠍一 碁煙 譟郁覈  碁煙 一危磯伎る .
GO

Create Table Rebuild_Index_Table(
   ObjectName CHAR (255),
   ObjectId INT,
   IndexName CHAR (255),
   IndexId INT,
   Lvl INT,
   CountPages INT,
   CountRows INT,
   MinRecSize INT,
   MaxRecSize INT,
   AvgRecSize INT,
   ForRecCount INT,
   Extents INT,
   ExtentSwitches INT,
   AvgFreeBytes INT,
   AvgPageDensity INT,
   ScanDensity DECIMAL,
   BestCount INT,
   ActualCount INT,
   LogicalFrag DECIMAL,
   ExtentFrag DECIMAL)
GO

INSERT INTO Rebuild_Index_Table
EXEC ('DBCC SHOWCONTIG WITH TABLERESULTS, ALL_INDEXES')
GO

--70% 危襦 譟郁 蟆
SELECT ObjectName, IndexName, CountPages,  
CAST(BestCount As Numeric) /  CAST(ActualCount As Numeric) * 100 'ScanDensity'
FROM Rebuild_Index_Table
WHERE CAST(BestCount As Numeric) /  CAST(ActualCount As Numeric) * 100 < 70
AND ObjectName NOT LIKE 'sys%'
AND ActualCount > 0
AND IndexName > ''

--碁煙  ろ襴渚
SELECT 'DBCC DBREINDEX ([' + CAST(RTRIM(ObjectName) AS VARCHAR(255)) + '],' + CAST(RTRIMIndexName) AS VARCHAR(255)) + ',' + '100)'
FROM Rebuild_Index_Table
WHERE CAST(BestCount As Numeric) /  CAST(ActualCount As Numeric) * 100 < 70
AND ObjectName NOT LIKE 'sys%'
AND ActualCount > 0
AND IndexName > ''

--碁煙 譟郁覈 ろ襴渚
SELECT 'DBCC INDEXDEFRAG(0,[' + CAST(RTRIM(ObjectName) AS VARCHAR(255)) + '],' + CASTRTRIM(IndexName) AS VARCHAR(255)) +')'
FROM Rebuild_Index_Table
WHERE CAST(BestCount As Numeric) /  CAST(ActualCount As Numeric) * 100 < 70
AND ObjectName NOT LIKE 'sys%'
AND ActualCount > 0
AND IndexName > ''

Drop table Rebuild_Index_Table
--碁煙 譟郁 覲企ゼ 覲願る Drop Table 讌 殊 .
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

蟲郁螳 蟆 朱譯殊. 企慨 讌 螻 蟇一碁慨 讌 ...(願 襴 螻旧)