To check space in SQL Server, you need to look at three layers: the files (.mdf data and .ldf log) on disk, the free space inside each file, and the free space on the volume hosting those files. Run a query against sys.database_files (or sp_helpdb) for per-file size and growth settings, check volume free space in Windows or with xp_fixeddrives, then break down usage by filegroup and table when you need to plan a fix. The most common mistake is checking only database size while the drive holding the log file is about to fill up.

This guide walks through that workflow in order — stored procedures first for a quick read, then catalog views for detail, then per-object breakdowns when the totals don't explain a problem. Everything uses stock SQL Server objects, so it works on SQL Server 2012 through 2022 and Azure SQL where noted.

Before you start: what you need and why the order matters

Prerequisites. Connect with an account that can view database metadata. Membership in the db_owner role (or VIEW DATABASE STATE plus read access to the database) covers the catalog views used below; sysadmin covers the server-level commands. You also need a way to see the host volume's free space — either Windows Explorer or Performance Monitor on the server, or xp_fixeddrives from T-SQL.

Why do files first, volume second, objects last? Space problems fall into two categories that look identical from the application side but have different fixes. Inside the database, free space in a file is wasted capacity you can often reclaim by shrinking or rebalancing. Outside the database, free space on the volume is a hard limit — if the log drive fills, SQL Server can't write transactions and the database stops accepting writes. File-level checks catch the second category immediately; object-level checks are for "why is this database 800 GB when the biggest table is 40 GB?"

Use the read-only queries below during business hours. Shrinking, moving files, and changing growth settings are separate maintenance actions that need their own change control — nothing here modifies your database.

Step 1: Quick per-database and per-file overview with stored procedures

Two built-in procedures give you a fast baseline without writing queries.

sp_helpdb lists every database on the instance with its size, owner, and status. Run EXEC sp_helpdb; for all databases or EXEC sp_helpdb N'YourDatabase'; for one. The single-database form reports each file, its current size, maximum size, growth increment, and physical path — the fastest way to see whether a log file has UNLIMITED growth on a small volume.

sp_spaceused reports the space used and reserved inside the currently connected database, or for a specific table. In the database context, run:

You get five numbers: database name, database_size (data plus log, in MB), unallocated space (reserved but not yet used by any object — often described as reserved space), reserved, data, and index_size. The key relationship: unallocated space plus reserved approximates the data-file portion of database_size. A large unallocated space value means the data file has grown well beyond what its objects currently occupy — that's your shrink candidate, though shrinking has fragmentation trade-offs covered later.

sp_spaceused N'dbo.Orders'; does the same for a single table, which is handy for confirming that a suspicious table really is the space hog. One caveat: the procedure pulls from allocation metadata, so the numbers are accurate but reflect the moment of execution; on a busy system with heavy allocation churn they can drift slightly between runs.

Step 2: Precise file sizes and free space from catalog views

For anything beyond a glance, query the metadata directly. The sys.database_files view (per database, in that database's context) has one row per file:

size and SpaceUsed are reported in 8 KB pages, so multiplying by 8 and dividing by 1024 converts to MB — that arithmetic is the only subtle part. free_mb is free space inside the file, not on the disk. A data file that is 200 GB with 150 GB free is a file-size problem; a volume with 5 GB free is a disk problem. Run this in each database you care about, or script it across databases with sp_MSforeachdb substitutes like sys.databases plus dynamic SQL.

At the server level, sys.master_files holds the same columns for every database in one place, but FILEPROPERTY works per-database, so the server-wide version usually reports size and path rather than used space. That's still enough to see where large files live and whether several databases pin their logs to the same volume.

Step 3: Confirm the host volume has free space

File metadata tells you about the database; only the operating system knows about the disk. Three reliable options on Windows-hosted SQL Server:

Windows Explorer or Disk Management on the server — simplest, but requires remote access or a console session. Performance Monitor logical disk counters (% Free Space) — best for monitoring, since it records history. xp_fixeddrives from T-SQL — returns drive letters with free MB:

That command gives one line per fixed drive with available space in MB. It's the fastest remote check, but on Azure SQL Database and Azure SQL Managed Instance, xp_fixeddrives isn't available (you don't administer the host), and on Linux-hosted SQL Server it returns only what the OS exposes to the process. If your logs and data share a volume — common in small deployments — xp_fixeddrives is the check that tells you the whole architecture is one full disk away from an outage.

The way to read it: if free MB on the log volume is small relative to the log file's growth, your next log backup or the next large transaction is the risk, not the database size.

Step 4: Log-specific checks, because logs behave differently

Transaction logs don't shrink the way data files do. The log file's physical size stays large until you back it up (full recovery model) or truncate it (simple recovery model), at which point the logical used portion resets but the file on disk doesn't. That gap confuses plenty of space investigations.

To see log usage per database:

used_mb here is the portion of the log file holding active and not-yet-truncated log records. A log file at 50 GB size with 2 GB used is a file-size problem (backups are truncating, all is well, but the file never shrank). A log file at 50 GB size and 49 GB used with a full recovery model and no recent log backups is a truncation problem — and it's urgent, because the next large transaction can fill the volume. The stop condition to watch for: if used space in the log is growing steadily and log backups aren't running, take a backup before running anything else; don't shrink first.

sys.dm_db_log_space_usage (SQL Server 2012+, available in Azure SQL) gives a cleaner per-database read with total_log_size_in_bytes, used_log_space_in_bytes, and used_log_space_in_percent for the current database, so you don't need FILEPROPERTY to compute it.

Step 5: Break the totals down by table and index

When per-file numbers show a database is genuinely full of data rather than slack, find the objects doing the filling. One efficient query over allocation views:

Pages are 8 KB, so total_pages * 8 / 1024 gives MB — reproducible, and total_mb minus used_mb is mostly index free space and internal fragmentation within pages. On a large database this query reads a lot of metadata; expect a few seconds. For responses that time out, restrict to one schema or run sp_spaceused per suspect table instead. This table-level view is also how you catch the classic surprise: LOB data (varchar(max), nvarchar(max), varbinary(max), XML) sitting in a table whose small row count made it look harmless.

For deeper analysis, sys.dm_db_index_physical_stats reports fragmentation and page counts per index, and extended events plus sys.dm_exec_query_stats help find the query causing the growth. Those are investigation tools for after you've identified the object.

How it all fits together: a worked read of the numbers

Suppose the queries return:

Data volume free space: 12 GB. YourDatabase.mdf: 180,000 MB size, 140,000 MB used → 40,000 MB free, about 22% free. YourDatabase.ldf: 60,000 MB size, 3,000 MB used → 57,000 MB free inside the file, on the same 12 GB-free volume.

What this sample tells you:

1: No immediate capacity emergency — 12 GB on the data volume is thin but not zero, and the log file's internal free space (57 GB) means new log records write into existing allocated space without growing the file first. 2: The data file has 40 GB of internal slack. That's wasted allocated space; a rebuild-based reclaim or a one-time shrink (followed by reindexing) can return most of it, but plan it. 3: Something caused both files to reach 240 GB total when only 143 GB is used. On a small volume, fixing the file sizes is arguably worth more than enlarging the disk.

Arithmetic you can hand to a reviewer: 180,000 + 60,000 = 240,000 MB total; 140,000 + 3,000 = 143,000 MB in active use; so roughly 97,000 MB — about 40% — is free space inside files. With 12 GB free on the volume, the risk number is 12 GB, not 97 GB.

The trade-offs hiding behind "free space"

Shrinking files isn't free. A shrink returns unused space to the OS but leaves fragmented pages and can re-grow under load. Common practice: shrink once, during a maintenance window, then reindex affected indexes. Repeated shrink/grow cycles are worse than letting the file stay sized. Check fragmentation with sys.dm_db_index_physical_stats before deciding.

Autogrow settings turn a space problem into a latency problem. Files grown in small increments cause frequent growth events; FILEGROWTH set by percentage is worse, because 10% of a 1 TB file is a 100 GB jump. Set fixed MB growth and cap MAXSIZE only when you mean it — a capped file that fills up fails transactions in a way that looks like a space problem but is really a configuration one.

Recovery model decides whether you have a log problem. In full recovery, log backups empower truncation; without them the log grows until the disk fills, regardless of anything you do in SQL Server. Checking log usage (Step 4) plus the backup history tells you which situation you're in before you touch the log file.

Checking Azure SQL and other non-standard setups

Azure SQL Database manages the filesystem, so host-volume checks don't apply; use sys.database_files, sys.resource_stats (database size in GB), and sys.dm_db_resource_stats for storage and growth trends, plus the portal's storage metric. Azure SQL Managed Instance exposes much of the instance-level T-SQL, but the underlying volumes are managed, so treat xp_fixeddrives results with suspicion. On Linux-hosted SQL Server, the same catalog views work, and the host free space comes from df -h on the affected mount, not from Windows commands. Availability Group replicas add one wrinkle: each replica has its own copy of the files on its own volumes, so capacity has to be checked on every replica, not just the primary.

A compact checklist you can rerun monthly

Layer What to check Where
Database summary Size, owner, per-file growth EXEC sp_helpdb N'db'
Files Size vs. used per file sys.database_files + FILEPROPERTY
Volume Free MB per drive xp_fixeddrives or Performance Monitor
Logs Size vs. used, truncation state sys.dm_db_log_space_usage + backup history
Objects Top tables/indexes by MB sys.allocation_units query
Trend Growth over time Performance Monitor / Azure metrics

Rerunning the table in this order gives a consistent month-over-month picture, and the per-file free-percentage column is the single best early warning: a steady decline with no matching usage increase means file growth is outrunning data, which is a configuration fix, not a disk purchase.

If the checks reveal a genuine emergency

Distinguish the two failure shapes before acting. Full log volume with truncation running: take a log backup, confirm the backup completed, and only then consider shrinking — the log truncates at backup completion, so the backup is the fix. Full log volume with truncation not running (full recovery, no log backups, or a long-running transaction holding log records): the backup won't help until the blocking transaction ends; find it in sys.dm_tran_active_transactions and sys.dm_exec_requests, and involve your DBA. Data file at MAXSIZE: raise the limit or add a file, but verify the volume has room, because a file added to a full disk fails the same way. If you're not certain which shape you're in, stop and get a DBA or the platform team involved — guessing at shrink or growth settings during an outage can turn a hiccup into downtime.