Export (0) Print
Expand All
Expand Minimize

DROP VIEW (Transact-SQL)

Removes one or more views from the current database. DROP VIEW can be executed against indexed views.

Topic link icon Transact-SQL Syntax Conventions


DROP VIEW [ schema_name . ] view_name [ ...,n ] [ ; ]

schema_name

Is the name of the schema to which the view belongs.

view_name

Is the name of the view to remove.

When you drop a view, the definition of the view and other information about the view is deleted from the system catalog. All permissions for the view are also deleted.

Any view on a table that is dropped by using DROP TABLE must be dropped explicitly by using DROP VIEW.

When executed against an indexed view, DROP VIEW automatically drops all indexes on a view. To display all indexes on a view, use sp_helpindex.

When querying through a view, the Microsoft SQL Server 2005 Database Engine checks to make sure that all the database objects referenced in the statement exist and that they are valid in the context of the statement, and that data modification statements do not violate any data integrity rules. A check that fails returns an error message. A successful check translates the action into an action against the underlying table or tables. If the underlying tables or views have changed since the view was originally created, it may be useful to drop and re-create the view.

For more information about determining dependencies for a specific view, see sys.sql_dependencies (Transact-SQL).

For more information about viewing the text of the view, see sp_helptext (Transact-SQL).

To execute DROP VIEW, at a minimum, ALTER permission on SCHEMA or CONTROL permission on OBJECT is required.

The following example removes the view Reorder.

USE AdventureWorks ;
GO
IF OBJECT_ID ('dbo.Reorder', 'V') IS NOT NULL
DROP VIEW dbo.Reorder ;
GO

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft