script 1911

  • http://qa.sqlservercentral.com/scripts/viewscript.asp?scriptid=1911

    I changed the exec (@command); to just print @command.

    now when trying to run script 1911, I get this:

    ALTER INDEX spt_valuesclust ON master.dbo.spt_values REBUILD

    Executed ALTER INDEX spt_valuesclust ON master.dbo.spt_values REBUILD

    ALTER INDEX ix2_spt_values_nu_nc ON master.dbo.spt_values REBUILD

    Executed ALTER INDEX ix2_spt_values_nu_nc ON master.dbo.spt_values REBUILD

    ALTER INDEX PK_SpaceUsed ON master.dbo.SpaceUsedResults REBUILD

    Executed ALTER INDEX PK_SpaceUsed ON master.dbo.SpaceUsedResults REBUILD

    ALTER INDEX clust ON msdb.dbo.sysjobhistory REBUILD

    Executed ALTER INDEX clust ON msdb.dbo.sysjobhistory REBUILD

    ALTER INDEX PK_sysmaintplan_taskdetail_id ON msdb.dbo.sysmaintplan_log REBUILD

    Executed ALTER INDEX PK_sysmaintplan_taskdetail_id ON msdb.dbo.sysmaintplan_log REBUILD

    ALTER INDEX pk_MSdbms_map ON msdb.dbo.MSdbms_map REBUILD

    Executed ALTER INDEX pk_MSdbms_map ON msdb.dbo.MSdbms_map REBUILD

    ALTER INDEX pk_MSdbms_datatype_mapping ON msdb.dbo.MSdbms_datatype_mapping REBUILD

    Executed ALTER INDEX pk_MSdbms_datatype_mapping ON msdb.dbo.MSdbms_datatype_mapping REBUILD

    ALTER INDEX PK__backupmediaset__6FB49575 ON msdb.dbo.backupmediaset REBUILD

    Executed ALTER INDEX PK__backupmediaset__6FB49575 ON msdb.dbo.backupmediaset REBUILD

    ALTER INDEX PK__backupmediafamil__719CDDE7 ON msdb.dbo.backupmediafamily REBUILD

    Executed ALTER INDEX PK__backupmediafamil__719CDDE7 ON msdb.dbo.backupmediafamily REBUILD

    ALTER INDEX PK__backupset__756D6ECB ON msdb.dbo.backupset REBUILD

    Executed ALTER INDEX PK__backupset__756D6ECB ON msdb.dbo.backupset REBUILD

    ALTER INDEX PK__backupfilegroup__7849DB76 ON msdb.dbo.backupfilegroup REBUILD

    Executed ALTER INDEX PK__backupfilegroup__7849DB76 ON msdb.dbo.backupfilegroup REBUILD

    ALTER INDEX PK__backupfile__7B264821 ON msdb.dbo.backupfile REBUILD

    Executed ALTER INDEX PK__backupfile__7B264821 ON msdb.dbo.backupfile REBUILD

    Msg 102, Level 15, State 1, Line 4

    Incorrect syntax near '('.

    =====

    I double check the ( and ' all appear to match up ok and none of them appear missing or too many.

  • I'm sorry, I'm not sure. I just did the same thing you described and it worked fine.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • Is there any chance that some of your object names, index names, (etc.) contain spaces or single upper quotes?

    It's not a very well written script. It doesn't take into account special characters in object names.

  • It's not a terribly well written script. We had a specific need and wrote it to meet that need and then stopped. We're extremely dilligent about keeping reserved words & special characters out our objects, but if we needed to, we could make the adjustment.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • I apologize if my posting implied that it was a terrible script. This was not my intension. Sorry. I only really skipped through some lines of codes in the script to find possible problems that would cause the error reported by the thread initiator.

    Special characters in object names are not a good practice (although sometimes unavoidable, like the underscore character).

    Again, sorry if I stepped on any toes. Wasn't my intension.

  • Not at all. If I thought I had something really cool & wonderful I'd be crushed. Instead, what I've got is a bit of a hack based on other people's work. What most people seemed to do with these scripts was write them to run on a single database. Instead, we wanted it to run all the databases on the system. Further, we needed to update it to run on 2005. That's really all the work I did, making those two changes.

    It certainly needs polish and posting information like this is helpful, not hurtful.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • I have only one end user database on that system now.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply