28 May 2024

MS SQL Server - Drop Database

 o remove your database from MS SQL Server, use drop database command. Following two methods can be used for this purpose.

Method 1 – Using T-SQL Script

Following is the basic syntax for removing database from MS SQL Server.

Drop database <your database name>

Example

To remove database name ‘Testdb’, run the following query.

Drop database Testdb
Method 2 – Using MS SQL Server Management Studio

Connect to SQL Server and right-click the database you want to remove. Click delete command and the following screen will appear.

Delete Object

Click OK to remove the database (in this example, the name is Testdb as shown in the above screen) from MS SQL Server.

MS SQL Server - Select Database

 Select your database based on your action before going ahead with any of the following methods.

Method 1 – Using SQL Server Management Studio

Example

To run a query to select backup history on database called ‘msdb’, select the msdb database as shown in the following snapshot.

Select Database

Method 2 – Using T-SQL Script

Use <your database name>

Example

To run your query to select backup history on database called ‘msdb’, select the msdb database by executing the following query.

Exec use msdb

The query will open msdb database. You can execute the following query to select backup history.

Select * from backupset

SQL Server Copilot AI

 Here are some of the latest tips and advanced concepts for Microsoft SQL Server (MS SQL) in 2024: 1. SQL Server Copilot AI Microsoft has in...