Scale database error.
Applies to: Azure SQL Database.
Date created: January 31, 2019.
Problem Description.
Trying to scale down an Azure SQL Database going from Standard S0 to Basic, I
received the following error message on Azure portal.
Scale database error
Failed to scale from Standard S0: 10 DTUs, 250 GB to Basic, 2 GB for database:
MyDatabaseName.
Error code: .
Error message: MODIFY MAXSIZE failed. To reduce the database size, the database
first needs to reclaim unused space by running DBCC SHRINKDATABASE. Note that
this operation can impact performance while it is running and may take several
hours to complete. Refer to the following article for details of using T-SQL to
run DBCC SHRINKDATABASE:
https://go.microsoft.com/fwlink/?linkid=852312
Cause.
This error message can be encountered when you try to scale down a database but
the current database size is above the size limit of the target service level.
In this case the target service level/tier was Basic which has a 2 GB database size
limit, but as you can see on the following image, the current database size was
2.92 GB.
Solution.
I proceeded as suggested on the error message and executed a DBCC SHRINKDATABASE
command while connected to the database using SQL Server Management Studio.
After running that command the database size was reduced below the 2 GB database
size limit as shown on below image. After that I was able to scale down
the service tier of the database to Basic.