Please disable your adblock and script blockers to view this page
 

How to delete all views from sql server database

IntroductionIn this article i will explain how to delete all the views from Sql server database.

Description: In previous articles i explained How to delete all stored procedures from sql server database and How to delete all triggers from sql server database and How to delete all tables from Sql server Database . Now going to share the command to delete all the created views from the Sql Server Database.
Note: This command will delete all the views from your database so use with care.

Implementation: In Sql server execute the following command:

Declare @viewName varchar(500)
Declare cur Cursor For Select [name] From sys.objects where type = 'v'
Open cur
Fetch Next From cur Into @viewName
While @@fetch_status = 0
Begin
 Exec('drop view ' + @viewName)
 Fetch Next From cur Into @viewName
End
Close cur
Deallocate cur 


Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily.. ConversionConversion EmoticonEmoticon