Table of Contents
Previous Section Next Section

Deleting a View

Finally, you can remove views from the database using the following:

DROP VIEW ViewName
DELETING A VIEW
Start example

Execute the following statement against the InstantUniversity database:

DROP VIEW ClassAttendees;

Then, try to execute the following statement:

SELECT * FROM ClassAttendees;

You'll receive an error message:

   Server: Msg 208, Level 16, State 1, Line 1

   Invalid object name 'Rolodex'.

The query in this example simply deletes the view used in the previous examples, restoring the database to its virgin state. The error shown might not match the one you get because this is a SQL Server error, but you'll definitely get an error of some sort!

End example

Table of Contents
Previous Section Next Section