Learn how to delete a SQL table from database permanently, SQL Drop Table Statement Example
Here you learn how to drop a table in SQL Server.
Remember that once you drop a table all data in that table will be lost, so be careful before executing Drop statement in SQL Server.
Drop is like you are deleting the object permanently from SQL Server, but in SQL Delete is considered as query statement.
So , here is how you can Drop a table.
// drop TABLE [schemaName].[tableName] drop TABLE [dbo].[tbTeacher]
If you want to just delete the data , think of delete or truncate but don’t drop the table.
If the table is referenced by FOREIGN KEY Constraint, then it will not allow you to drop the table, and throw an exception "Could not drop object 'table' because it is referenced by a FOREIGN KEY constraint"
If you get the above error while dropping a table, you need to delete the Foreign Key Constraint first, then will be able to drop the table.
ALTER TABLE [TableName] DROP CONSTRAINT FK_ConstName; ALTER TABLE ClassStudentMap DROP CONSTRAINT FK_ClassStudentMap_ClassRoom;