Server::Databases Property

 

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

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

public:
[SfcObjectAttribute(SfcContainerRelationship::ObjectContainer, 
	SfcContainerCardinality::ZeroToAny, (Database^::typeid), SfcObjectFlags::Design)]
property DatabaseCollection^ Databases {
	DatabaseCollection^ get();
}

Property Value

Type: Microsoft.SqlServer.Management.Smo::DatabaseCollection^

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

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.

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()
Return to top
Show: