To delete a database, you use the DROP DATABASE expression followed by the name of the database. The formula used is:
DROP DATABASE DatabaseName;Here is an example:
DROP DATABASE RealEstate1;
GOTo start from a sample code, open an empty Query window and display the Template Explorer. From the Template Explorer, expand Database. Drag the Drop Database node and drop it in the Query window:-- =========================
-- Drop Database Template
-- =========================
USE master
GO
IF EXISTS (
SELECT name
FROM sys.databases
WHERE name = N'<Database_Name, sysname, Database_Name>'
)
DROP DATABASE <Database_Name, sysname, Database_Name>
GO
To delete a database in SQL Server Management Studio, in the Object Explorer, expand the Databases node, right-click the undesired database, and click Delete. A dialog box would prompt you to confirm your intention
If you still want to delete the database, you can click OK. If you change your mind, you can click Cancel
Comments
Post a Comment