From the course: Microsoft SQL Server 2022 Essential Training

Unlock this course with a free trial

Join today to access over 24,100 courses taught by industry experts.

Delete records from a table

Delete records from a table

- We've seen how to add records to a table with the insert into statement and the values clause. Now let's take a look at removing records from a table. The first step is to make sure that you can identify the record that you want to remove. Let's start up a new query and make sure we're targeting the Red30Tech database. Then I'll just select everything from the customer's table. I'll execute the query and we'll see we have a total of 1,002 rows that represent all of our customers. So let's suppose that I need to remove Eric Bryant's record. It's this one on this row right there. To do this, I could start with a command, DELETE FROM Customers. Now, if I run this line number four, right now SQL Server will actually remove all of the data from the table, because I haven't limited the scope of the delete. You do that with a criteria. Just like in a select statement, we specify a filter or a selection criteria with a WHERE…

Contents