December 2015
Intermediate to advanced
760 pages
14h 31m
English
This recipe shows how you can drop a database using PowerShell and SMO.
This task assumes you have created a database called TestDB. If you don't have it, create the database TestDB by following the steps in the Creating a database recipe.
Here are the steps to drop your TestDB database:
#import SQL Server module Import-Module SQLPS -DisableNameChecking #replace this with your instance name $instanceName = "localhost" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName
$dbName = "TestDB" #need to check if database exists, and ...
Read now
Unlock full access