Last active
April 26, 2017 01:30
-
-
Save gregjhogan/c1e1747ecb5a62c2cea00ccbcf0d7598 to your computer and use it in GitHub Desktop.
Shrink an Azure SQL database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DBCC SHRINKFILE ('data_0', TRUNCATE ONLY) | |
| DBCC SHRINKFILE ('log', TRUNCATE ONLY) | |
| -- view used/available space | |
| SELECT | |
| name, | |
| CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 as SpaceUsedInMB, | |
| size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB | |
| FROM sys.database_files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment