Collections:
"DROP" Statements - Deleting database objects in SQL Server
How to delete database objects with "DROP" statements in SQL Server?
✍: FYIcenter.com
To remove all database objects created by previous tutorials, you could just delete the database. However, in this tutorial, you will go through the steps to reverse every action you took doing the tutorial.
Removing permissions and objects - Before you delete objects, make sure you are in the correct database:
USE TestData; GO
Use the REVOKE statement to remove execute permission for Mary on the stored procedure:
REVOKE EXECUTE ON pr_Names FROM Mary; GO
Use the DROP statement to remove permission for Mary to access the TestData database:
DROP USER Mary; GO
Use the DROP statement to remove permission for Mary to access this instance of SQL Server 2005:
DROP LOGIN [<computer_name>\Mary]; GO
Use the DROP statement to remove the store procedure pr_Names:
DROP PROC pr_Names; GO
Use the DROP statement to remove the view vw_Names:
DROP View vw_Names; GO
Use the DELETE statement to remove all rows from the Products table:
DELETE FROM Products; GO
Use the DROP statement to remove the Products table:
DROP Table Products; GO
You cannot remove the TestData database while you are in the database; therefore, first switch context to another database, and then use the DROP statement to remove the TestData database:
USE MASTER; GO DROP DATABASE TestData; GO
⇒ Database Engine Tutorials from SQL Server 2005 Books Online
⇐ "GRANT EXECUTE" Statements - Granting EXECUTE permission in SQL Server
⇑ Getting Started with Transact-SQL Statements in SQL Server
2016-11-27, 2053🔥, 0💬
Popular Posts:
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...
How To Verify Your PHP Installation in MySQL? PHP provides two execution interfaces: Command Line In...
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Round a Numeric Value To a Specific Precision in SQL Server Transact-SQL? Sometimes you need ...