DROP TABLE command in SQL Server
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 should read it
May be interested
- LOCAL TEMPORARY TABLE in SQL Serverthis tutorial explains how to use local temporary table in sql server with syntax and examples.
- GOTO command in SQL Serverthe goto command is a simple jump command, which allows an unconditional jump program from goto to a location in the program that has a label (laber) command in the same function.
- Clean command in Windowsthe clean command deletes all partitions or formats the volume from the current drive. the command applies to windows server (semi-annual channel), windows server 2019, windows server 2016, windows server 2012 r2, windows server 2012.
- DELETE TOP command in SQL Serverthe delete top command in sql server is used to delete records from a table in sql and limits the number of records based on an existing value or percentage.
- CASE function in SQL Server (part 1)in sql server, the case function verifies the value based on the list of given conditions, then returns one or more results. in this article we will illustrate a number of different uses of this function in different situations.
- The sfc command in Windows(applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
- The cacls command in Windowsthe cacls command displays or modifies an arbitrary access control list (dacl) on the specified file. the command applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012.
- CREATE TABLE command in SQL to create a database tablewhat does the create table command in sql do? in this article, let's learn everything you need to know about the create table statement in sql!
- CASE statement in SQL Serverthis article will show you in detail how to use the case statement handling function in sql server with specific syntax and examples to better visualize and capture functions.
- SEQUENCE in SQL Serversequence is often used in databases because it is necessary for many applications. the article will provide syntax and examples of how to create and delete the sequence and its attributes in sql server.