Microsoft® SQL Server™ 2008 All-In-One Desk Reference For Dummies®
by Robert D. Schneider, Darril Gibson
II.5.5. Deleting a Table
When the time comes to bid farewell to a table, follow these simple steps and it will be gone from your life forever (unless you've made a backup, in which case the table has achieved immortality — and you still have a copy of the backup).
Launch SQL Server Management Studio.
Connect to the appropriate SQL Server instance.
Expand the connection's entry in the Object Explorer view.
Expand the Databases folder.
Expand the Tables folder.
Highlight the table you want to delete.
Press Delete.
If the table is part of a relationship, and removing the table violates the terms of the relationship, SQL Server reports an error and blocks the deletion of this table. For example, take a look at the error message we received when we erroneously tried to delete a table that others depended upon:
Drop failed for Table 'dbo.students'. (Microsoft.SqlServer.Smo) An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) Could not drop object 'dbo.students' because it is referenced by a FOREIGN KEY constraint. (Microsoft SQL Server, Error: 3726)
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
