Indexes tables in an Azure database if they have a high fragmentation

This runbook indexes all of the tables in a given database if the fragmentation is above a certain percentage. It highlights how to break up calls into smaller chunks, in this case each table in a database, and use checkpoints. Please read the runbook for additional information.

4.5 Star
12,022 times
Add to favorites
Windows Azure
E-mail Twitter Digg Facebook
  • Support for non "dbo" schemas
    1 Posts | Last post September 12, 2017
    • Hi,
       This is more of a hint than a question:
      If you have tables in schemas other than dbo, you'll need to change a line in there 
      SELECT '[' + + '].[' + + ']' AS TableName, t.OBJECT_ID FROM sys.tables t
      join sys.schemas s on s.schema_id=t.schema_id
  • The server was not found or was not accessible
    1 Posts | Last post February 17, 2017
    • When I attempt to test the Runbook I receive the error "The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections". I'm confident that the Server Name parameter I'm supplying is correct, but my Sql Server is located in a different region to my Automation Account - is this an issue and do you have to specify a firewall rule on the Sql Server to allow the Runbook script to access it? I have "Allow access to Azure services" turned on in the Sql Server firewall settings.
      Many thanks
  • SqlCredential Name parameter
    2 Posts | Last post July 10, 2015
    • I'm trying to set up this script to run, and I'm running into problems with getting the SqlCredentialName parameter to work.  I've created both a connection and a certificate and added them in the assets for the automation account 
      (based on )
      but the script fails with "unable to retrieve "SqlCredentialName %1".
      Obviously I'm not creating the correct type of credential for SqlCredential. Could someone offer a link to a walk thru of creating one for a particular Azure Sql DB.
    • Hey Matthew
      Following this ->
      ...worked for me!
      Thanks Paul