I tried multiple times and finally concluded that when multiple SQL Server tables are associated with update, an as Alias cannot be added to an external table, and a syntax error is returned.
Only the table name can be written as the prefix for reference and cannot be referenced using an alias.
The syntax can be referred to below
Update a set Field 1 = B table field expression, field 2 = B table field expression from B WHERE logical expression
For example:
The code is as follows: |
Copy code |
UPDATE dbo. Table2 SET dbo. Table2.ColB = dbo. Table2.ColB + dbo. Table1.ColB FROM dbo. Table2 Inner join dbo. Table1 ON (dbo. Table2.ColA = dbo. Table1.ColA ); |
Example 1:
Count the total revenue of a clerk in the current month's business system, and update it to the clerk table.
The code is as follows: |
Copy code |
Update user set user. money = yeji_as.full_money from ( Select sum (day_money) as full_money, user_id from yewu where yewu_date = '2013' group by user_id ) As yeji_as where yeji_as.user_id = user. user_id |