Deleting the Database

This section describes the procedure for deleting a database using the OSQL command.
Refer to the documentation included with the management tools of each database for information about deleting databases using the management tools of each database.
1.
Displays the command prompt.
Windows Server 2003:
Select [All Programs] → [Accessories] → [Command Prompt] from the Start menu.
Windows Vista/7/Server 2008/Server 2008 R2:
Select [All Programs] → [Accessories] from the Start menu → right-click [Command Prompt] → select [Run as administrator].
In the [User Account Control] dialog box, click [Continue] or [Yes].
Windows 8/Server 2012
Enter 'Command Prompt' in [Search] in the Charms → right-click [Command Prompt] → select [Run as administrator].
2.
Enter the following command to log in to the database as an administrator.
OSQL -S < server name>\< instance name > -U sa -P <system administrator (sa) password>
If you access a default instance of the database on server computer, enter <server name>. If you access a named instance, enter <server name>\<instance name>.
Example: OSQL -S iwmc-server\iwmc-instance -U sa -P password
3.
Stop all access to the database.
Enter the following command:
EXEC SP_WHO
GO
If the database you want to delete is displayed under [dbname], make a note of the value displayed under [spid].
Enter the following command:
KILL <value under [spid]>
GO
Example:
KILL 51
GO
If multiple instances of the database to delete are displayed in the [dbname] field, enter the above command for each [spid].
If you use the KILL command, all access to the database is stopped. Before executing the KILL command, confirm that the database is not being used.
4.
Enter the following commands to delete the database.
DROP DATABASE <database name>
GO
EXIT
Example: DROP DATABASE iWMC_DB
GO
The database is deleted.