December 2, 2008 at 8:23 am
I am tryingto automate re indexing based on the fragmentation.
some thing like this.
IF @frag < 30.0
SET @command = N'ALTER INDEX ' + @indexname + N' ON ' +
@schemaname + N'.' + @objectname + N' REORGANIZE';
IF @frag >= 30.0
SET @command = N'ALTER INDEX ' + @indexname + N' ON ' +
EXEC (@command);
PRINT N'Executed: ' + @command;
I would like to get an out put message so that i can know which indexes are rebuild, either in a email or a text file. How can i do it?
December 2, 2008 at 8:46 am
I've used this http://www.sqlservercentral.com/scripts/Index+Management/30721/ before to log reindexing, I think it works on SQL 2005 as well you'd need to try it.
December 2, 2008 at 10:46 am
Mike Levan (12/2/2008)
I am tryingto automate re indexing based on the fragmentation.some thing like this.
IF @frag < 30.0
SET @command = N'ALTER INDEX ' + @indexname + N' ON ' +
@schemaname + N'.' + @objectname + N' REORGANIZE';
IF @frag >= 30.0
SET @command = N'ALTER INDEX ' + @indexname + N' ON ' +
EXEC (@command);
PRINT N'Executed: ' + @command;
I would like to get an out put message so that i can know which indexes are rebuild, either in a email or a text file. How can i do it?
A number of ways are possible. One really simple one that comes to mind is to build a temporary table, insert the indexes you update into it and then select from that at the end of your process.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
December 3, 2008 at 11:15 am
This SSC article does ONLINE/OFFLINE re-index, and sends report in Email
http://www.sqlservercentral.com/scripts/SQL+Server+2005/61278/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply