Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Friday, 6 February 2015

Introduction

In this article i will explain how to delete all the views from Sql server database.
We can delete all views by executing single query. We don’t need to execute different query for each View.
Note: This command will delete all the views from your database.


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 
Categories: , ,

0 comments:

Post a Comment