Server.Databases Server.Databases Server.Databases Property

Definition

Represents a collection of Database objects. Each Database object represents a database defined on the instance of SQL Server.

public:
 property Microsoft::SqlServer::Management::Smo::DatabaseCollection ^ Databases { Microsoft::SqlServer::Management::Smo::DatabaseCollection ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObject(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerRelationship.ObjectContainer, Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerCardinality.ZeroToAny, typeof(Microsoft.SqlServer.Management.Smo.Database), Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObjectFlags.Design)]
public Microsoft.SqlServer.Management.Smo.DatabaseCollection Databases { get; }
Public ReadOnly Property Databases As DatabaseCollection
Property Value

A DatabaseCollection object that represents all the databases defined on the instance of SQL Server.

Examples

Visual Basic

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = $srv.Databases.Item("AdventureWorks2012")  
$tb = $db.Tables.Item("Person", "Person")  
$col = $tb.Columns.Item("LastName")  
$col.Nullable = $TRUE  
$col.Alter()  

Remarks

Specific databases can be referenced by using this collection and specifying the name of the database. To create a new database, call the database constructor Database.

Applies to

See Also