How to delete a SQL Server view?

How to delete a SQL Server view from the database? For a SQL developer it’s a good practice to have a clean database and remove the unused or useless code. Unlike the tables, the views can be deleted from the database using a SQL command.

How to delete a SQL Server view from the database?

Let’s consider the Sales by month view created in this article. To drop the view, simply use this SQL command and execute it against the database.

DROP VIEW 
	[dbo].[SalesByMonth] ;
GO
    

Note that deletion is possible only for user defined views, not the system views using database catalog data.

Be the first to comment

Leave a Reply