| Start |
|---|
| Drop temporary tables In SQL server we have 2 types of temporary tables:
Droping process of temporary tables is the same as for normal table: BEFORE SQL Server 2016: SQL Server 2016: |
| Drop tables The DROP TABLE command remove the table definitions and all data, indexes, triggers, constraints and related permissions. Before you drop a table, you should check if there are any object (views, stored procedures, other tables) that reference the table. You cannot drop a table referenced by another table by FOREIGN KEY. You must first drop the FOREIGN KEY referencing it. You can drop a table referenced by a view or stored procedure, but after dropping the table, the view or stored procedure is no longer usable. The Syntax
Examples Remove the table with name TABLE_1 from current database and default schema dbo Remove the table with TABLE_1 from database HR and default schema dbo Remove the table with TABLE_1 from database HR and schema external |
| Drop Databases The DROP DATABASE command removes a database catalog, regardless of its state (offline, read-only, suspect, etc.), from the current SQL Server instance. A database cannot be dropped if there are any database snapshots associated with it, as the database snapshots must be dropped first. A database drop removes all of the physical disk files (unless it's offline) used by the database unless you use the Stored Procedure 'sp_detach_db'. A database snapshot drop deletes the snapshot from the SQL Server instance and deletes the physical files also used by it. A dropped database can only be re-created by restoring a backup (not from a database snapshot either). The Syntax
Examples Remove a single database; Removing multiple databases Removing a snapshot Removing if database exists RemarksLinks to MSDN. |
Read Article
https://develop.horje.com/learn/1434/reference