Master SQL Server From Scratch

Clear, interactive, and structured SQL Server lessons designed for beginners and developers.

COURSE SYLLABUS
1. Introduction to SQL Server
Introduction to SQL Server SQL Server Installation SQL Server Fundamentals
2. Data Types
Data Types Numeric Data Types Character & String Data Types Date & Time Data Types Other SQL Server Data Types
3. Database & Tables
Database & Tables Introduction Creating a Database Creating Tables Table Structure Altering Tables Dropping Tables
4. Constraints
Constraints Introduction PRIMARY KEY FOREIGN KEY UNIQUE Constraint NOT NULL & DEFAULT CHECK Constraint
5. SQL Basics
SQL Basics Introduction SQL Commands SQL Command Categories SELECT Statement INSERT, UPDATE & DELETE
6. CRUD Operations
CRUD Operations Introduction INSERT Operation SELECT Operation UPDATE Operation DELETE Operation
7. SQL Queries
Queries Introduction WHERE Clause ORDER BY Clause DISTINCT LIKE Operator IN, BETWEEN & IS NULL
8. Joins
Joins Introduction INNER JOIN LEFT JOIN RIGHT JOIN FULL OUTER JOIN CROSS JOIN
9. SQL Functions
SQL Functions Introduction String Functions Numeric Functions Date & Time Functions Conversion Functions NULL Functions
10. Grouping & Aggregate Functions
GROUP BY Aggregate Functions COUNT() SUM() AVG() MIN() & MAX()
11. Subqueries
Subqueries Introduction Single-Row Subquery Multiple-Row Subquery Correlated Subquery Subquery with DML
12. Views
SQL Views Introduction Creating a View Updating a View Altering a View Dropping a View
13. Stored Procedures
Stored Procedures Introduction Creating a Stored Procedure Input Parameters Output Parameters Executing & Modifying Stored Procedures
14. Triggers
Triggers Introduction AFTER INSERT Trigger AFTER UPDATE Trigger AFTER DELETE Trigger INSTEAD OF Trigger
15. Transactions
Transactions Introduction COMMIT ROLLBACK SAVEPOINT Transaction with TRY...CATCH
16. Indexes
Indexes Introduction Clustered Index Non-Clustered Index Creating & Dropping Indexes Index Performance
17. Common Table Expressions
CTE Introduction Simple CTE CTE with JOIN CTE with Aggregate Functions Recursive CTE
18. Window Functions
Window Functions Introduction ROW_NUMBER() RANK() and DENSE_RANK() LEAD() and LAG() PARTITION BY
19. Advanced SQL
Advanced SQL Introduction Temporary Tables Table Variables Dynamic SQL Error Handling Performance Optimization

Dropping a View

Learn how to permanently remove an existing SQL Server View using the DROP VIEW statement.

What is DROP VIEW?

The DROP VIEW statement is used to permanently remove an existing View from a SQL Server database.

When a View is dropped, the View object and its definition are removed from the database.

Dropping a View does not delete the underlying table data. The tables used by the View remain in the database unless they are separately deleted.

DROP VIEW Syntax

DROP VIEW ViewName;
Syntax Explanation
  • DROP VIEW specifies that a View should be removed.
  • ViewName is the name of the View that needs to be deleted.

Example View

Suppose we have a View named EmployeeDetailsView:

CREATE VIEW EmployeeDetailsView
AS
SELECT
    EmployeeId,
    EmployeeName,
    Department,
    Salary
FROM Employees;

We can retrieve its data using:

SELECT *
FROM EmployeeDetailsView;

Dropping the View

To permanently remove the View, use:

DROP VIEW EmployeeDetailsView;

After executing this statement, the EmployeeDetailsView View is removed from the database.

Verify That the View Was Dropped

We can check the Views available in the current database using the system catalog:

SELECT
    name
FROM sys.views;

If the View was successfully dropped, its name will no longer appear in the list.

Dropping Multiple Views

Multiple Views can be removed by executing separate DROP VIEW statements.

DROP VIEW EmployeeDetailsView;

DROP VIEW EmployeeSalaryView;

Each statement removes its corresponding View.

Using DROP VIEW IF EXISTS

SQL Server also supports checking whether a View exists before dropping it.

DROP VIEW IF EXISTS EmployeeDetailsView;

This statement drops the View if it exists. If the View does not exist, SQL Server does not raise the usual missing-object error for the DROP operation.

DROP VIEW vs DELETE

DROP VIEW DELETE
Removes a View object. Removes rows from a table.
Removes the View definition. Does not remove the table itself.
Does not directly delete underlying table data. Deletes selected table records.

Important Warning

Dropping a View removes the View object from the database. Applications, queries, reports, or stored procedures that depend on that View may stop working.

Always verify dependencies before dropping a View in a production database.

Best Practices

  • Verify the View name before executing DROP VIEW.
  • Check whether applications depend on the View.
  • Use DROP VIEW IF EXISTS when appropriate.
  • Avoid dropping Views directly in production without checking dependencies.
  • Test database changes in a development environment before applying them to production.

Summary

The DROP VIEW statement permanently removes an existing SQL Server View. Dropping a View removes the View object and its definition, but it does not directly delete the data stored in the underlying tables. Always check dependencies before dropping a View.