How to use Delete Command in SQL Server?
Introduction:
In this article i will explain what is Delete command and how to use Delete command in SQL Server.
Description:
In previous articles i explained How to create a table in SQL Server, How to alter table column in SQL Server, How to add a column to table and How to delete a column from table in SQL Server, How to rename a column and How to rename a table in SQL Server, and Update Command. Now i will explain what is Delete command and how to use Delete command in SQL Server.
Here i'm using Employee table.
Delete command is used to delete particluar records from table. While deleting records we can specify conditions in where clause. Where clause is optional.
Syntax:(1)
Delete from <table-name>
Syntax:(2)
Delete from <table-name> where <column-name> = <value>
Example:
Delete from Employee where EmpNo = 4
Execute the above statement.
Output:
Important:
- If we omit the where condition all the records will be deleted.
- Records will be deleted in sequential manner.
-
CreatedSep 22, 2013
-
UpdatedNov 03, 2020
-
Views2,903
Related Articles
Different types of variables in SQL Server
What is Cross Join in SQL Server
How delete record from parent table when there is Foreign Key relation in SQL Server
What is the differences between CHAR, NCHAR, VARCHAR and NVARCHAR in SQL Server?
How to add or remove a column from a table in SQL Server?
How to insert values into Identity Column in SQL Server?
How to get a fixed-length value in SQL Server?
What is Left Join (or) Left Outer Join in SQL Server?
How to get current week dates in SQL Server?
What are the different types of Date formats in SQL Server?