Last active
May 3, 2017 19:16
-
-
Save ronascentes/6166d90460d74ecba2a21aac45dc3c9b to your computer and use it in GitHub Desktop.
Like sp_spaceused but much better
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
USE <db_name> | |
GO | |
SELECT SUM((size/128.0))/1024 AS [Total Size in GB], | |
SUM(CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0)/1024 AS [Space Used in GB], | |
SUM(size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0)/1024 AS [Available Space in GB], | |
sum((((size)/128.0) - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0)) / sum(((size)/128.0)) * 100 as '% Available' | |
FROM sys.database_files WITH (NOLOCK) | |
--WHERE type = 1 -- log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment