乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      整理索引碎片(本腳本從邏輯碎片著手)

       Jason(徐子) 2010-09-19
      /*Perform a 'USE <database name>' to select the database in which to run the script.*/
      -- Declare variables
      SET NOCOUNT ON
      DECLARE @tablename VARCHAR (128)
      DECLARE @execstr   VARCHAR (255)
      DECLARE @objectid  INT
      DECLARE @indexid   INT
      DECLARE @frag      DECIMAL
      DECLARE @maxfrag   DECIMAL
      -- Decide on the maximum fragmentation to allow
      SELECT @maxfrag = 30.0
      -- Declare cursor
      DECLARE tables CURSOR FOR
         SELECT TABLE_NAME
         FROM INFORMATION_SCHEMA.TABLES
         WHERE TABLE_TYPE = 'BASE TABLE'
      -- Create the table
      CREATE TABLE #fraglist (
         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)
      -- Open the cursor
      OPEN tables
      -- Loop through all the tables in the database
      FETCH NEXT
         FROM tables
         INTO @tablename
      WHILE @@FETCH_STATUS = 0
      BEGIN
      -- Do the showcontig of all indexes of the table
         INSERT INTO #fraglist
         EXEC ('DBCC SHOWCONTIG (''' + @tablename + ''')
            WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS')
         FETCH NEXT
            FROM tables
            INTO @tablename
      END
      -- Close and deallocate the cursor
      CLOSE tables
      DEALLOCATE tables
      -- Declare cursor for list of indexes to be defragged
      DECLARE indexes CURSOR FOR
         SELECT ObjectName, ObjectId, IndexId, LogicalFrag
         FROM #fraglist
         WHERE LogicalFrag >= @maxfrag
            AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0
      -- Open the cursor
      OPEN indexes
      -- loop through the indexes
      FETCH NEXT
         FROM indexes
         INTO @tablename, @objectid, @indexid, @frag
      WHILE @@FETCH_STATUS = 0
      BEGIN
         PRINT 'Executing DBCC INDEXDEFRAG (0, ' + RTRIM(@tablename) + ',
            ' + RTRIM(@indexid) + ') - fragmentation currently '
             + RTRIM(CONVERT(varchar(15),@frag)) + '%'
         SELECT @execstr = 'DBCC INDEXDEFRAG (0, ' + RTRIM(@objectid) + ',
             ' + RTRIM(@indexid) + ')'
         EXEC (@execstr)
         FETCH NEXT
            FROM indexes
            INTO @tablename, @objectid, @indexid, @frag
      END
      -- Close and deallocate the cursor
      CLOSE indexes
      DEALLOCATE indexes
      -- Delete the temporary table
      DROP TABLE #fraglist
      GO

       

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多