Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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: 4207 | Views in the last 30 days: 4
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...


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones