Collections:
"DROP SCHEMA" - Dropping an Existing Schema in SQL Server
How To Drop an Existing Schema in SQL Server?
✍: FYIcenter.com
If you want to delete a schema, you need to move all objects out of that schema, then use the "DROP SCHEMA" statement to delete the schema. The tutorial exercise below shows you how to drop schema "fyi":
-- Login with "sa" USE FyiCenterData; GO -- Drop failed because schema is not empty DROP SCHEMA fyi; GO Msg 3729, Level 16, State 1, Line 1 Cannot drop schema 'fyi' because it is being referenced by object 'DF__fyi_links__creat__4316F928'. -- Move one table out ALTER SCHEMA dbo TRANSFER fyi.fyi_links; GO -- Delete one table DROP TABLE fyi.test; GO -- Dropped ok DROP SCHEMA fyi; GO Command(s) completed successfully.
2016-10-20, 646👍, 0💬
Popular Posts:
How to create new tables with "CREATE TABLE" statements in SQL Server? If you want to create a new t...
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How to execute statements under given conditions in SQL Server Transact-SQL? How to use IF ... ELSE ...
How To Count Rows with the COUNT(*) Function in SQL Server? If you want to count the number of rows,...