DROP TABLE command in SQL Server

In SQL Server, the DROP TABLE command is used to delete a table from the database.

In SQL Server, the DROP TABLE command is used to delete a table from the database.

Syntax of DROP TABLE command

  DROP TABLE ten_bang; 

Variable name or variable value

ten_bang

The name of the table you want to delete the database key of SQL Server.

For example

  DROP TABLE is available; 

The command in the above example will delete the table from the current database in SQL Server. But if the table you want to delete is not in the current database but in another database, see how to delete the table in another database below.

  DROP TABLE cosodulieu2.dbo.nhacung; 

For example, the above DROP TABLE command will delete the table that is not in the current database but in the database named cosodulieu2.

Because of the mention of the CASL name, the DROP TABLE command can execute on any database of the server installation (as long as you have the right to execute the command).

Now see the example of deleting LOCAL TEMPORARY TABLE with the DROP TABLE command. Remember that LOCAL TEMPORARY TABLE comes with the # character in front.

  DROP TABLE #nhanvien; 

This command will delete the local temporary table named #nhanvien.

Here is an example of deleting the GLOBAL TEMPORARY TABLE with the DROP TABLE command. This table starts with the ## character.

  DROP TABLE ##nhacung; 

The above command will delete the global temporary table ## nhacung.

Previous article: ALTER TABLE command in SQL Server

The following article: VIEW in SQL Server

You've just finished reading the article "DROP TABLE command in SQL Server" edited by the TipsMake team. You can save drop-table-command-in-sql-server.pdf to your computer here to read later or print it out. We hope this article has provided you with many useful tech tips and tricks. You can search for similar articles on tips and guides. Thank you for reading and for following us regularly.

« PREV VIEW in SQL Server
NEXT » ALTER TABLE statement in SQL Server