Azure SQL Database – Comprehensive Guide to Database Maintenance

azure-sql-databaseindex-maintenancemaintenancesql serverstatistics

If SQL Agent isn't available for Azure SQL Database then is it possible to maintain (indexes, statistics etc) the databases with Ola Hallengren's maintenance scripts, for example?

Best Answer

Once you have created an Azure SQL Database you can use all tools listed on the following image to provide maintenance:

enter image description here

Regarding to Ola Hallengren's maintenance scripts, you can install them using psdbatool on a Managed Instance

enter image description here

Learn more about psdbatool here.

You can also install them manually.

And run them.

EXECUTE dbo.IndexOptimize
@Databases = 'mydbnamehere',
@FragmentationLow = NULL,
@FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 30,
@UpdateStatistics = 'ALL',
@OnlyModifiedStatistics = 'Y'

You may also need Azure Automation to schedule execution.