This documentation is archived and is not being maintained.

Database.Size Property

Gets the size of the database in MB.

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

public double Size { get; }

Property Value

Type: System.Double
A Double value that specifies the database in MB.

The size is specified in megabytes and should be the same as when the database was originally created unless you have opted to automatically grow or shrink the database. The space allocated in the database can be determined by using the SpaceAvailable property.

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server

'Reference the AdventureWorks database.
Dim db As Database
db = srv.Databases("AdventureWorks")

'Display size and space information for the database.
Console.WriteLine("data space usage (KB): " + _
Console.WriteLine("index space usage (KB): " + _
Console.WriteLine("space available (KB): " + _
Console.WriteLine("database size (MB): " + _