Sql 使用将值从一个表覆盖到另一个表

Sql 使用将值从一个表覆盖到另一个表,sql,sql-server,datatable,overwrite,Sql,Sql Server,Datatable,Overwrite,我有两张桌子,顾客和新顾客。对于特定列,我想用newCustomer表覆盖customer表的列值。例如: customer.firstname = newCustomer.firstname customer.lastname = newCustomer.lastname **我有两个表的匹配ID 我可以从编码的角度考虑如何做到这一点,但在考虑用SQL实现这一点时,我遇到了困难 我正在使用Microsoft SQL Server 如果您有任何示例或提示,我们将不胜感激。您可能拥有连接两个表的

我有两张桌子,顾客和新顾客。对于特定列,我想用newCustomer表覆盖customer表的列值。例如:

customer.firstname = newCustomer.firstname
customer.lastname = newCustomer.lastname
**我有两个表的匹配ID

我可以从编码的角度考虑如何做到这一点,但在考虑用SQL实现这一点时,我遇到了困难

我正在使用Microsoft SQL Server


如果您有任何示例或提示,我们将不胜感激。

您可能拥有连接两个表的id。如果是这样,只需使用
join
set

update c
    set firstname = nc.firstname,
        lastname = nc.lastname
    from customer c join
         newcustomer nc
         on c.customerid = nc.customerid;

请提供示例数据和所需结果。@GordonLinoff我有一个名为Customer和newCustomer的表。所以我想让customer.firstname=newCustomer.lastname。