Export (0) Print
Expand All
Expand Minimize

Table.DataSpaceUsed Property

Gets the storage space used by the rows of the referenced table in kilobytes.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Expensive|SfcPropertyFlags.Standalone|SfcPropertyFlags.Matrix)]
public double DataSpaceUsed { get; }

Property Value

Type: Double
A Float64 value that specifies the storage space of the rows of data in the table, in kilobytes.

The value is the actual amount of disk space that is required to store the row data of the referenced table. SQL Server can allocate additional, unused space to a Table object.

The following code example shows how to display the amount of storage space used by each table in the AdventureWorks2012 database.

C#

Server srv = new Server("(local)");
Database db = srv.Databases["AdventureWorks2012"];

foreach (Table tb in db.Tables)
{
   Console.WriteLine("The " + tb.Name + " table is " + tb.DataSpaceUsed.ToString() + " KB in size.");
}

Powershell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("AdventureWorks2012")

Foreach ($tb in $db.Tables)
{
   Write-Host "The" $tb.Name "table is" $tb.DataSpaceUsed "KB in size."
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft