DELETE
The DELETE
is a T-SQL command of type DML.
Syntax
DELETE FROM <table_name>WHERE <condition>;GO
Arguments
<table_name>
: Table name to delete data from.<condition>
: TheWHERE
clause applied to the search result.
Before you begin
Create a backup table
USE AdventureWorks2019;GOSELECT *INTO Production.Product_backupFROM Production.Product;GO
Delete all rows
DELETE FROM PRODUCTION.PRODUCT_BACKUP;
(504 rows affected)Completion time: 2021-10-07T00:44:18.4932582-07:00
Delete selected rows
Please re-create the Product_backup table as in the above query.
You can delete some of the rows based on a WHERE
clause.
DELETE FROM Production.Product_backupWHERE safetystocklevel > 500;
(181 rows affected)Completion time: 2021-10-07T00:45:12.7313869-07:00
The
DELETE
statement only removes the data from the table, but the schema structure remains. You can also roll back this transaction.
Did you find this page helpful?
Start with GraphQL on Hasura for Free
- Build apps and APIs 10x faster
- Built-in authorization and caching
- 8x more performant than hand-rolled APIs