Database.Drop Database.Drop Database.Drop Method

Definition

Drops the database.

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

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 Drop method removes the database from the instance of SQL Server. If the database cannot be dropped, (possibly because of open connections), you can use KillAllProcesses to close the connection(s) and drop the database.

Applies to