How To: Generate reindex statements only


Sometimes it is useful to generate index maintenance statements and run them by hand, individually or in small groups. To generate reindex statements without running the statements, run the procedure Minion.IndexMaintMaster with the parameter @StmtOnly set to 1. 

Example code - The following code will generate index statements for all tables in the [YourDatabase] database with the ONLINEopt set to "ONLINE" (that is, all tables that are configured to be maintained in online operations only). 


EXEC [Minion].[IndexMaintMaster] 
  @IndexOption = 'ONLINE',
  @ReorgMode = 'All',
  @RunPrepped = 0, 
  @PrepOnly = 0,
  @StmtOnly = 1,
  @Include = 'YourDatabase', 
  @Exclude = NULL, 
  @LogProgress = 1;