| title | Deleting Database Objects | Microsoft Docs | |
|---|---|---|
| ms.custom | ||
| ms.date | 03/14/2017 | |
| ms.prod | sql-server-2016 | |
| ms.reviewer | ||
| ms.suite | ||
| ms.technology |
|
|
| ms.tgt_pltfrm | ||
| ms.topic | article | |
| applies_to |
|
|
| helpviewer_keywords |
|
|
| ms.assetid | dbb94fdf-c85b-477b-8e84-f830d259bade | |
| caps.latest.revision | 21 | |
| author | BYHAM | |
| ms.author | rickbyh | |
| manager | jhubbard |
To remove all traces of this tutorial, you could just delete the database. However, in this topic, you will go through the steps to reverse every action you took doing the tutorial.
-
Before you delete objects, make sure you are in the correct database:
USE TestData; GO -
Use the
REVOKEstatement to remove execute permission forMaryon the stored procedure:REVOKE EXECUTE ON pr_Names FROM Mary; GO -
Use the
DROPstatement to remove permission forMaryto access theTestDatadatabase:DROP USER Mary; GO -
Use the
DROPstatement to remove permission forMaryto access this instance of [!INCLUDEssVersion2005]:DROP LOGIN [<computer_name>\Mary]; GO -
Use the
DROPstatement to remove the store procedurepr_Names:DROP PROC pr_Names; GO -
Use the
DROPstatement to remove the viewvw_Names:DROP View vw_Names; GO -
Use the
DELETEstatement to remove all rows from theProductstable:DELETE FROM Products; GO -
Use the
DROPstatement to remove theProductstable:DROP Table Products; GO -
You cannot remove the
TestDatadatabase while you are in the database; therefore, first switch context to another database, and then use theDROPstatement to remove theTestDatadatabase:USE MASTER; GO DROP DATABASE TestData; GO
This concludes the Writing [!INCLUDEtsql] Statements tutorial. Remember, this tutorial is a brief overview and it does not describe all the options to the statements that are used. Designing and creating an efficient database structure and configuring secure access to the data requires a more complex database than that shown in this tutorial.
Tutorial: Writing Transact-SQL Statements
REVOKE (Transact-SQL)
DROP USER (Transact-SQL)
DROP LOGIN (Transact-SQL)
DROP PROCEDURE (Transact-SQL)
DROP VIEW (Transact-SQL)
DELETE (Transact-SQL)
DROP TABLE (Transact-SQL)
DROP DATABASE (Transact-SQL)