Home

spspaceused

sp_spaceused is a system stored procedure in Microsoft SQL Server and Azure SQL Database that reports space usage for a database or a specific table. It is commonly used for capacity planning, auditing storage growth, and quick spot checks of how space is allocated.

When executed without parameters, sp_spaceused returns database-level information, including the database_name, database_size, and unallocated_space. The values

The @updateusage parameter controls whether the procedure recalculates space usage before returning results. Setting @updateusage = 'true'

Examples:

- EXEC sp_spaceused;

- EXEC sp_spaceused @objname = 'dbo.Orders';

- EXEC sp_spaceused @updateusage = 'true';

Notes and caveats:

sp_spaceused is a legacy-style utility useful for quick assessments but may not reflect real-time fragmentation or

are
presented
in
megabytes.
When
a
table
name
is
supplied
via
the
@objname
parameter,
the
procedure
returns
table-level
statistics
such
as
name,
rows,
reserved,
data,
index_size,
and
unused.
The
numeric
columns
for
the
table
view
are
typically
in
kilobytes,
reflecting
the
space
reserved
and
used
by
the
table.
forces
an
up-to-date
scan,
which
can
be
I/O
intensive
and
may
take
longer
on
large
databases
or
tables.
The
default
is
usually
'false',
meaning
the
results
reflect
existing
statistics.
per-partition
details.
For
deeper
analysis,
consider
catalog
views
and
dynamic
management
views
such
as
sys.dm_db_partition_stats,
sys.dm_db_file_space_usage,
or
other
storage-related
tools.
It
remains
a
commonly
referenced
starting
point
for
storage
questions
in
SQL
Server
environments.