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.

Update records in a table

Update records in a table

- [Instructor] Records in your data tables will occasionally need to be modified. To do this with a SQL query you'll use an update statement. Let's suppose one of our customers called the company and they want to change their order quantity. I'll start a new query and I'll just select everything from the orders table to get started. When I execute the query, we'll see that we actually only have a single order at this point in our database. Customer ID 1000 belongs to our friend Catherine Reed again. She wants to get five of the same product instead of two. To modify her order, we'll write a quick update statement. We need to target the update to this specific order ID from the table. So we'll update the orders table, then we'll set the value. I want to change the quantity, so I'll target the quantity column, and I'm going to say the quantity is equal to five. Now, just like with the delete statement we need to be really careful…

Contents