The tutorial describes how to convert a SELECT query to an UPDATE query using the Query Builder tool:
For demo purposes, we are going to use the table Production.Document from the AdventureWorks2019 database. First, retrieve data from the table to view the data. To do this, in the Database Explorer, right-click the table and select Retrieve Data.
Next, we will create a query that updates all records for the Owner column where it is equal to 217, and change it to 218.
1. In the Database Explorer, right-click the table and select Send to > Query Builder. The SELECT query for the table was created.
Alternatively, from the Database Explorer, drag the table to the diagram.
2. Switch to the Where tab to specify the selection condition.
3. Click Add and do the following:
If the Tabbed Editor is not displayed, you can open it by clicking Show Tabbed Editor on the Query toolbar or main menu.
4. Execute the query to preview the result. The records with the Owner column that equals 217 are displayed.
5. Change the query type from SELECT to UPDATE. To do this, right-click the diagram and select Change Type > Update. The statement has been converted to the UPDATE statement.
6. On the diagram, select the Owner column and set its value to 218 on the Update tab.
7. Execute the query and view the result.
As you can see, all the records where Owner was equal to 217 were changed to 218.
Watch the video to see how to create a SQL UPDATE statement using the Query Builder tool.