Ms sql updating one table from another
For the Sales YTD column, I simply specify a literal value, which in this case is 0.
For the Sales Last Year column, I increase the value by 5% by multiplying the column by 1.05.
By using an UPDATE statement, you can modify data in individual rows, sets of rows, or all rows in a table.
An UPDATE statement must always include a SET clause, which identifies the columns to be updated.
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.The following example modifies the data in the Sales Staff table by changing the value of the Sales Quota column to 250000.Notice that I first specify the UPDATE keyword, followed by the name of the table-Sales Staff.When specifying the table or view, be sure to qualify the name with the schema, database, and server names, as necessary.After I specify the table, I define the SET clause.