How to shrink Azure SQL server DB (18MB of data charged for 5GB of server space already)

Pekka Ylenius picture Pekka Ylenius · Oct 30, 2013 · Viewed 13k times · Source

I have problem with Azure SQL DB. Bacpack export of DB is only 18MB but charged DB size of server exceeds 5GB already.

Is there any way to see actual size of data?

Is there any way to move DB to simple recovery model? Or is there any other way to shrink log files?

Or should I just drop Database and restore from backup?

Answer

Pekka Ylenius picture Pekka Ylenius · Oct 31, 2013

Problem was caused by defragmented indexes.

You can find good scripts for fixing those from here: http://blogs.msdn.com/b/dilkushp/archive/2013/07/28/fragmentation-in-sql-azure.aspx

After running scripts (and 24h) size of DB went back to 300MB.