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.
Thanks for reading the article. Please let me know your comment.
0 comments:
Please let me know your view