Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - "DROP" Statements - Deleting database objects
(Continued from previous topic...)
How to delete database objects with "DROP" statements?
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
Removing permissions and objects -
Before you delete objects, make sure you are in the correct database:
Use the REVOKE statement to remove execute permission for Mary on the stored procedure:
REVOKE EXECUTE ON pr_Names FROM Mary;
Use the DROP statement to remove permission for Mary to access the TestData database:
DROP USER Mary;
Use the DROP statement to remove permission for Mary to access this instance of SQL Server 2005:
DROP LOGIN [\Mary];
Use the DROP statement to remove the store procedure pr_Names:
DROP PROC pr_Names;
Use the DROP statement to remove the view vw_Names:
DROP View vw_Names;
Use the DELETE statement to remove all rows from the Products table:
DELETE FROM Products;
Use the DROP statement to remove the Products table:
DROP Table Products;
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:
DROP DATABASE TestData;
- How to use Transact-SQL statements to access the database engine?
- How to create new databases with "CREATE DATABASE" statements?
- How to create new table with "CREATE TABLE" statements?
- How to insert and update data into a table with "INSERT" and "UPDATE" statements?
- How to read data in a table with "SELECT" statements?
- How to create a login to access the database engine using "CREATE LOGIN" statements?
- How to create a user to access a database using "CREATE USER" statements?
- How to create a view and a stored procedure using "CREATE VIEW/PROCEDURE" statements?
- How to grant a permission using "GRANT EXECUTE" statements?
- How to delete database objects with "DROP" statements?