Database.Create Database.Create Database.Create Method

Definition

Creates a database on the instance of SQL Server as defined by the Database object.

Overloads

Create() Create() Create()

Creates a database on the instance of SQL Server as defined by the Database object.

Create(Boolean) Create(Boolean) Create(Boolean)

Creates a database on the instance of SQL Server as defined by the Database object.

Create() Create() Create()

Creates a database on the instance of SQL Server as defined by the Database object.

public:
 virtual void Create();
public void Create ();
Public Sub Create ()

Examples

VB

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "Test_SMO_Database")  
$db.Create()  
Write-Host $db.CreateDate  
$db.Drop()  

Remarks

The Create method creates the database on the instance of SQL Server. You can create a Database object variable and set properties, but the database is not created on the instance of SQL Server until the Create method is called.

Create(Boolean) Create(Boolean) Create(Boolean)

Creates a database on the instance of SQL Server as defined by the Database object.

public:
 void Create(bool forAttach);
public void Create (bool forAttach);
Public Sub Create (forAttach As Boolean)
Parameters
forAttach
Boolean Boolean Boolean

A Boolean value that specifies whether the database is being created so that a database can be attached.

If True, the database is created for a database to be attached. Otherwise, False.

Examples

VB

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "Test_SMO_Database")  
$db.Create()  
Write-Host $db.CreateDate  
$db.Drop()  

Remarks

The Create method creates the database on the instance of SQL Server. You can create a Database object variable and set properties, but the database is not created on the instance of SQL Server until the Create method is called.

Applies to