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 - SQL Server Tutorial
From the course: Microsoft SQL Server 2022 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Understand the role of T-SQL2m 40s
-
(Locked)
Use the T-SQL editor6m 49s
-
(Locked)
Create a table with T-SQL6m 33s
-
(Locked)
Solution: Create tables with T-SQL commands3m 46s
-
(Locked)
Add data to a table4m 58s
-
(Locked)
Solution: Add data with T-SQL commands3m 4s
-
(Locked)
Retrieve records with SELECT4m 3s
-
(Locked)
Solution: Query data in a database2m 7s
-
(Locked)
Filter returned results with WHERE3m 12s
-
(Locked)
Sort records2m 54s
-
(Locked)
Solution: Filter and sort data with a query4m 27s
-
(Locked)
Delete records from a table4m 31s
-
(Locked)
Update records in a table2m 3s
-
(Locked)
Solution: Remove and update records in a table6m 11s
-
(Locked)
Joining related tables4m 32s
-
(Locked)
Solution: Query information from related tables5m 33s
-
(Locked)
Remove a table from the database5m 7s
-
-
-
-
-
-