Update Query with INNER JOIN between tables in 2 different databases on 1 server

后端 未结 11 1319
梦如初夏
梦如初夏 2020-12-08 09:29

Need some SQL syntax help :-)

Both databases are on the same server

db1 = DHE
db2 = DHE_Import

UPDATE DHE.dbo.tblAccounts 
INNER JOIN DHE_Import.dbo         


        
11条回答
  •  星月不相逢
    2020-12-08 09:36

    Sorry its late, but I guess it would be of help to those who land here finding a solution to similar problem. The set clause should come right after the update clause. So rearranging your query with a bit change does the work.

    UPDATE DHE.dbo.tblAccounts 
    SET DHE.dbo.tblAccounts.ControllingSalesRep
        = DHE_Import.dbo.tblSalesRepsAccountsLink.SalesRepCode
    from DHE.dbo.tblAccounts 
    INNER JOIN DHE_Import.dbo.tblSalesRepsAccountsLink 
        ON DHE.dbo.tblAccounts.AccountCode
            = DHE_Import.tblSalesRepsAccountsLink.AccountCode 
    

提交回复
热议问题