From the course: SQL Server 2008 Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Writing UPDATE statements - SQL Server Tutorial
From the course: SQL Server 2008 Essential Training
Writing UPDATE statements
Well just about as often as inserting information you're going to need to update information too. Let say the example that I was looking at, I know that I've got a problem with one of these rows. This last row here a ProductCategoryID 55 should have had a ParentProductCategoryID of 1 instead of 2. So let's see how to go ahead and do a simple example like that. We will use the word UPDATE and we're going to pick the table name, which is in this case SalesLT.ProductCategory. And just as SELECT has a FROM and INSERT has INTO, UPDATE has a SET. We're going to SET. We want to say what the values that we want to change are. In this case it was actually ParentProductCategoryID. IntelliSense is smart enough to know that if we're working with the ProductCategory table these are the only options that we have. And then I can say and in this case I'm going to do quite a specific change SET ParentProductCategoryID equal to 1. But if I were to run this code right now it would update every single…
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.