Export (0) Print
Expand All

Database.Drop Method ()

 

Applies To: SQL Server 2016 Preview

Drops the database.

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

No code example is currently available or this language may not be supported.

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.

Legacy Code Example

VB

Code snippet is not found. Confirm that the code snippet name 'SMO How to' is correct.

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()
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft