Updating records in sql
You can issue an UPDATE statement against a table or updateable view, as long as the statement modifies data in only one base table at a time.
By using an UPDATE statement, you can modify data in individual rows, sets of rows, or all rows in a table.
The clause identifies which columns in the target table should be modified and what the new values should be.
The following example modifies the data in the Sales Staff table by changing the value of the Sales Quota column to 250000.
You need to have a consistent definition of which direction is "up" and which is "down" for the concept of top to be meaningful.
Nonetheless SQL Server allows it but doesn't guarantee a deterministic result.
Note, however, that the data is slightly different in the Adventure Works database from what’s stored in the Adventure Works2008 database, so your results will be different than what is shown here. (Only the last example might need to be modified, which I’ll explain when we get to it.) To try out the examples in the article, you must first create the Sales Staff table, as shown in the following Transact-SQL code: Notice that I tag on a SELECT statement at the end of the code to retrieve the new content in the Sales Staff table.
For example, in the following example, I update the territory name for any row whose Full Name value is Jae Pak: Basically, I’m undoing the change I made in the previous statement by assigning the United Kingdom value to the Territory Name column. The following table shows the updated rows returned by the SELECT statement: As the examples demonstrate, the WHERE clause determines only which rows should be updated, whereas the SET clause is concerned only with updating column values.The WHERE clause specifies the search conditions that define which rows in the target table should be updated.In the following UPDATE statement, I modify only the rows that have a Territory Name value of United Kingdom: As you can see, I specify in the SET clause that the Territory Name value should be changed to UK.For the Sales Last Year column, I increase the value by 5% by multiplying the column by 1.05.The following table shows the results returned by the SELECT statement after I update the three columns: As you can see, updating column values is a very straightforward process when using an UPDATE statement.