How to rename and drop a Database from SQL Server using command and Management Studio?
Rename Database in SQL Server-
There are two ways to change the name of a Database in SQL Server.
1- By using SQL sp_renamedb Command-
Syntax- EXEC sp_renamedb 'oldDbName' , 'newDbName' ;
Example- The following SQL statement is used to change the existing database name 'Employees' to 'EmployeeDetails'
EXEC sp_renamedb 'Employees' , 'EmployeeDetails';
2- By using SQL ALTER Command-
syntax- ALTER DATABASE oldDbName MODIFY NAME = newDbName ;
Example- The following SQL statement is used change the existing Database name 'EmployeeDetails' to 'Employees'
alter database EmployeeDetails modify name = Employees;
Delete Database in SQL Server-
Drop or Delete the Database using SQL Command -
Syntax- DROP DATABASE databaseName;
Example- The following SQL statement is used to delete the database.
drop database DemoDB;
Delete Database by using SQL Server Management Studio-
To delete the Database from you SQL Server Management Studio. follow the below steps
Go To Object Explorer ---> Select Database you want to Delete ---> Right click on that Database name -----> Select 'Delete' option from Option Menu.
After click on Delete option a window open on your screen as like below. In which you click on OK