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)

2008 Index Rebuild using DMV

By Tommy Bollhofer,

Previous Version (http://www.sqlservercentral.com/scripts/SQL+Server+2005/61278/)

Iterates through sys.tables; performs an online index rebuild on indexes where the logical fragmentation is greater than or equal to the @LogicalFragmentationPercent parameter. The procedure can perform offline rebuild on indexes containing text, ntext, image, xml, varchar(max), varbinary(max) and nvarchar(max) or an offline rebuild by partition. This procedure is intended to reside in the msdb database and will conditionally create and populate a table called dbo.index_maintenance_history, configured via the @MaintainHistory parameter. This procedure can also produce and HTML report via the @EmailNotification paramter.

To utilize this with RedGate's SQL Script Manager, please save T-SQL above as  usp_DBA_index_maintenance_SSC.sql along with the *.rgtool code, preferably in the C:\ProgramData\Red Gate\SQL Scripts Manager directory.

In the past several readers have posted problems w/ downloading the T-SQL from the WYSWYG editor. Should you encounter any of these types of issues, I've made the scripts available via my SkyDrive

Total article views: 1564 | Views in the last 30 days: 4
 
Related Articles
FORUM

Rebuilding indexes

Rebuilding indexes

FORUM

Rebuild Index Script by srihari nandamuri

Rebuild Index Script by srihari nandamuri

FORUM

Rebuild Index

Rebuild Index

FORUM

Rebuild/Reorganize Indexes

This rebuild index script does not rebuild indexes when the script is run from the master database.

FORUM

INDEX REBUILD

Rebuilding indexes for better performance.

Tags
indexing    
maintenance    
sql server 2005    
sql server 2008    
 
Contribute

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
Editor, SQLServerCentral.com

Already a member? Jump in:

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