SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Index Fragmentation

By Sergio Govoni,

To print commands ALTER INDEX ... REORGANIZE or REBUILD for the indices of database TestDB with avg_fragmentation_in_percent greater than 10 (%) is sufficient run:

EXEC USP_ExecReorgRebuildIndex 'TestDB', 0, -1, 10

To run the defragmenter, use instead:

EXEC USP_ExecReorgRebuildIndex 'TestDB', -1, 0, 10

Total article views: 4262 | Views in the last 30 days: 2
Related Articles

The concurrent snapshot for publication 'TESTDB' is not available

The concurrent snapshot for publication 'TESTDB' is not available because it has not been fully gene...


failed to complete the command BACKUP LOG "TestDB" WITH TRUNCATE_ONLY

Guys, I have the following issue: In my SQL Server Logs I got the following error message: 'BACKU...


Synchronize several stored procedure between two servers

Synchronize source code between two servers for multiple stored procedures


Restore after removing database file - Can't recover database

What is wrong with my restore sequence?


how know the MAX_QUEUE_READERS value of a queue

Hi, Which queries I have to write to know the value of MAX_QUEUE_READERS setted on a existing que...