How To Delete All Records From A Table In SQL Server

I used to receive frequent requests to clear data from my database, so I deleted all records from tables using multiple approaches. I will walk you through all the approaches to do this.

Note: Before deleting the record from the table, properly back up it for the safer side.

Approach-1: Using the DELETE Statement

Check out: How To Drop All Constraints On A Table In SQL Server

One primary method is the DELETE Statement, which deletes all the records from a table in the SQL server.

Syntax

DELETE FROM TableName;

Example

Let us delete all the records from the Order table. Before that, let us see the records in the Order table using the select query below.

Select * from [Order]

After executing the above query, we got the lists of records available in the Order table.

delete all data from table sql

Now, we will execute the below query to delete all the records.

DELETE FROM [Order];

After executing the above query, the query was executed successfully, as shown in the screenshot below.

sql query to delete all rows in a table without deleting the table

Now, to cross-check, let us verify using the select query below.

Select * from [Order]

Now, you can see the data got deleted successfully, and there is no data available in this table, as shown in the screenshot below.

How To Delete All Records From A Table In SQL Server

Approach-2: Using the TRUNCATE TABLE statement

You can check out how to truncate a table in SQL server for the complete steps.

Conclusion

You can use the Delete table/Truncate table statement to delete the records from a table in the SQL server. For faster operation, you can use the Truncate table statement. Refer to the above information for the complete steps.

You may also like following the articles below.