Difference between revisions of "Maintenance of MS SQL Database (vCentre)"

Jump to navigation Jump to search
→‎Defragment Indexes: Added for HEAP
(Reworked for SQL2008+)
(→‎Defragment Indexes: Added for HEAP)
Line 28: Line 28:
USE VCDB                                                                          // Update with your database name
USE VCDB                                                                          // Update with your database name
ALTER INDEX PK_VPX_HIST_STAT4_106 ON VPX_HIST_STAT4_106 REORGANIZE
ALTER INDEX PK_VPX_HIST_STAT4_106 ON VPX_HIST_STAT4_106 REORGANIZE
</source>
For tables without an index (shows <code>NULL</code> in IndexName in the results), rebuild the whole table, so for example
<source lang="sql">
USE VCDB                                                                          // Update with your database name
ALTER TABLE VPX_STAT_COUNTER REBUILD
</source>
</source>


Line 41: Line 47:
ORDER BY indexstats.avg_fragmentation_in_percent DESC
ORDER BY indexstats.avg_fragmentation_in_percent DESC
</source>
</source>


=== Pre SQL 2008 ===
=== Pre SQL 2008 ===

Navigation menu