MSDN Docs

DROP (Transact‑SQL)

The DROP statement removes an existing database object, such as a table, view, stored procedure, or index. Once dropped, the object and its data are no longer available.

Syntax

DROP <object_type> [ IF EXISTS ] <object_name> [ , <object_name>... ] [;]

Common <object_type> values include:

Object TypeExample
TABLEDROP TABLE dbo.Customers;
VIEWDROP VIEW dbo.vCustomerSummary;
PROCEDUREDROP PROCEDURE dbo.usp_GetOrders;
FUNCTIONDROP FUNCTION dbo.fn_CalculateTax;
INDEXDROP INDEX IX_CustomerName ON dbo.Customers;

Parameters

  • IF EXISTS – Prevents an error if the object does not exist.
  • object_name – The schema‑qualified name of the object to drop.
  • ; – Optional statement terminator.

Examples

-- Drop a table if it exists
DROP TABLE IF EXISTS dbo.OldOrders;
-- Drop multiple objects in a single statement
DROP VIEW dbo.vSalesSummary, dbo.vCustomerActivity;
/* Remove an index */
DROP INDEX IX_EmployeeLastName ON dbo.Employees;

Remarks

Dropping an object is a non‑reversible operation. Ensure you have backups or have verified that the object is no longer needed before executing a DROP statement.

When dropping tables that have dependent objects (such as foreign key constraints), you must first drop or alter those dependencies.

See Also