Home » Topic » How Can I Check Free Space in My SQL Server Database?

How Can I Check Free Space in My SQL Server Database?

Lincoln Burrows ~ Modified: January 20th, 2016 ~ ~ 1 Minute Reading

Home Forums How Can I Check Free Space in My SQL Server Database?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1052 Score: 0
    Lincoln Burrows
    Moderator
    16 pts

    Is there any method or way to determine the free space in SQL Server Database ?

    #1057 Score: 0
    Stephen West
    Moderator
    4 pts

    you can try DBCC SQLPERF to determine the free space of your SQL Database.

    USE master 
    GO 
    DBCC SQLPERF(logspace)
    #1067 Score: 0
    Andrew Jackson
    Moderator
    1 pt

    You can also use FILEPROPERTY to check for free space in a SQL Server database

    USE AdventureWorks 
    GO 
    
    SELECT DB_NAME() AS DbName, 
    name AS FileName, 
    size/128.0 AS CurrentSizeMB,  
    size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB 
    FROM sys.database_files;

    This will show how much space is used by SQL Server database and then you can calculate free space

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.