T-SQL 101: 136 Deleting Rows from a SQL Server Table

The DELETE statement is one of the most common SQL statements. We use it to remove rows from a table.
In the example, I’ve said to delete rows from the dbo.CinemaGroups table where the value in the CinemaGroupID column is greater than 3.
You need to make sure that your DELETE statements have WHERE clauses, unless what you’re intending to do is delete all the rows in the table. You don’t want to make the common mistake where people highlight a DELETE statement in SQL Server Management Studio and forget to include the WHERE clause as well.
If you really do intend to remove all the rows in the table, a TRUNCATE statement might be what you should be using. It’s usually drastically faster but it requires different permissions, and won’t fire DELETE triggers for the rows being removed. You need the additional permissions to execute it, as it’s more of an administrative statement.
In the DELETE statement, the word FROM is optional. I’ve shown that in the second example.
Learning T-SQL
It’s worth your while becoming proficient in SQL. If you’d like to learn a lot about T-SQL in a hurry, our Writing T-SQL Queries for SQL Server course is online, on-demand, and low cost.
2025-03-28