For My query
exec sp_spaceused 'tablbename'
It returns
name | rows | reserved | data | index size | unused
But, I need only reserved field.
Displays the number of rows, disk space reserved, and disk space used by a table, indexed view, or Service Broker queue in the current database, or displays the disk space reserved and used by the whole database.
One simple way to do this is to use sp_spaceused to get the space used for a table.
Reserved: The space reserved for use by database objects = (Data +Index + Unused) = 476704 + 1280 + 1312 = 479296 KB. This indicates how full the objects are; ideally, 10% of unused space is expected for transactional tables. Data: The actual size of the data. This is the sum of all the data files of the database.
Try this, but I hope there is a better way
DECLARE @spaceUsed TABLE (
name varchar(255),
rows int,
reserved varchar(50),
data varchar(50),
index_size varchar(50),
unused varchar(50))
INSERT INTO @spaceUsed
exec sp_spaceused 'YOUR_TABLE'
SELECT reserved FROM @spaceUsed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With