• Add a parameter @online to the stored procedure, and then change the statement building line to:

    SET @command = N'ALTER INDEX ' + @indexname + N' ON ' + @schemaname + N'.' + @objectname + N' REBUILD WITH (ONLINE=' + isnull(@Online, 'ON') + ')';

    Many DBAs have their own version of the index rebuild/reorganize script.

    Some other good params that I have:

    @SpecifiedTableName,-- Specify the name of the table, null = all

    @SpecifiedIndexName,-- Specify the name of the index, null = all

    @FillFactor,-- Specify the fill factor, null = existing fill factor