UPDATE: This stored procedure has been updated.
I have modified isp_ALTER_INDEX, which is the stored procedure that I use to defragment indexes in SQL Server 2005. The changes include one bug fix and one feature request.
The bug fix was simply to add "SET QUOTED_IDENTIFIER ON" to the script. You'd only see the bug in special circumstances, such as if you were using indexed views.
The feature request was to add the ability to log the fragmentation data. The logged data could be used to determine if you want to rearrange the index or perhaps add/remove columns to reduce fragmentation. The logged data is stored in a table called DefragmentIndexes. If you don't want to log the data, then you'll still need to create the table if you want to use this new version, otherwise the CREATE PROC statement would fail due to a missing object. To configure the stored procedure to log the data, simply pass 1 to the new input parameter, @logHistory. The default for this new input parameter is 0, so you do not need to modify your job if you don't care about this new feature.
You can download the new version of the stored procedure and the required table here. I put them in the same script to make it easier to deploy the new version.
Let me know if you run into any issues with it.