The SQL Server DELETE Query is utilized to erase the current records from a table.
You need to utilize WHERE statement with DELETE inquiry to erase chosen columns, in any case all the records would be erased.
Syntax
Following is the fundamental sentence structure of DELETE inquiry with WHERE provision −
DELETE FROM table_name
WHERE [condition];
You can join N number of conditions utilizing AND OR administrators.
Example
Consider the CUSTOMERS table having the accompanying records −
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
6 Komal 22 MP 4500.00
7 Muffy 24 Indore 10000.00
Following order is a model, which would DELETE a client, whose ID is 6 −
DELETE FROM CUSTOMERS
WHERE ID = 6;
Clients table will currently have the accompanying records.
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
7 Muffy 24 Indore 10000.00
In the event that you need to DELETE all the records from CUSTOMERS table, you don't have to utilize WHERE proviso. Erase question would be as per the following −
DELETE FROM CUSTOMERS;
Clients table presently won't have any record.