Wednesday, 1 April 2020

SQL View Drop Query

4/01/2020 - By Pranav Singh 0

 This article will show you how you can drop all MS Sql View by using one query. So, here are the query. To data base object.

Drop Single View:
So here is the DB view




DROP VIEW  Test_View;


In above query Test_View is an SQL view. After executing the above query we will get output as below.



Now check the database.



Drop Multiple View:

In this we will check how to drop all SQL view of database. This will help you to drop all view in one go.

DECLARE @sqlquery VARCHAR(MAX) = '' , @crlf VARCHAR(2) = CHAR(13) + CHAR(10) ;
SELECT @sqlquery = @sqlquery + 'DROP VIEW ' + QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(myview.name) +';' + @crlf
FROM   sys.views myview

PRINT @sqlquery;
EXEC(@sqlquery);

The above query will generate multiple drop view query and execute it to drop the views. Now run the query. You will get message as shown below.



YouTube Video Link





Thanks for reading the article. Please let me know your comment.

Tags:
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top