SQL Deleting Views Trouble

J3Brother
J3Brother used Ask the Experts™
on
I am using SQL Server 2008 R2 Studio Manager and using the Northwind Database.
I created 4 views, emp_vu1, prod_cat_vu, m_emp_vu, and mexico_cust_vu and I am having trouble deleting these views.

This is the code:

DROP VIEW emp_vu1
DROP VIEW prod_cat_vu
DROP VIEW m_emp_vu
DROP VIEW mexico_cust_vu

I get an error that says:
"Cannot Drop the View because it does not exist or you do not have permission"

The views are their since I created them but just cannot drop them.
Please help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kevin CrossChief Technology Officer
Most Valuable Expert 2011
Commented:
Hi. Please note the last portion of the error, "you do not have permission." Is there a possibility that the account you are using does not have the DROP VIEW permission? What schema did you create the views in originally? i.e., double check that you are in the correct database and referencing the views with the proper qualified name.
Commented:
please check view name in sys.view  system view  or you can see all these in view folder in management studio. if these all view are able to see it then check drop permission and database  also.
Commented:
it could also be that you are trying to execute a delete for the views on the incorrect database.

Try to use this syntax:

Use MyDb (replace it with the database where the views reside)
GO

Drop view MyView1
Drop view MyView2
etc

/Martin
Senior Consultant
Commented:
Connect to SQL server through SQL Server Management Studio, create a DROP view script from there. ( Please see the picture ) . Execute the drop script on the database. ( To confirm whether this is a real permission issue )
DropViewIf drop command fails; this could be a  permission issue, you should grant required permissions ( say for example GRANT ALTER ON view to the user).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial