2022-09-27

SQL Update table from one database from other table from another database

I am trying to perform an update from a table in one database from another table in another database. One table has a number of lat/lon and I want to update the other one with those based on the matching address.

I have tried this:

UPDATE
    WENS_IMPORT.dbo.new_import 
SET
 WENS_IMPORT.dbo.new_import.lat = WENS.dbo.SUBSCRIPTION.lat,
 WENS_IMPORT.dbo.new_import.lon = WENS.dbo.SUBSCRIPTION.lon
FROM
 WENS.dbo.SUBSCRIPTION AS Table_A
 INNER JOIN WENS_IMPORT.dbo.new_import AS Table_B
    ON Table_A.streetAddress = Table_B.Address
WHERE
 Table_A.account_id = '388' AND Table_A.active = '1'

I thought this was the best route but I keep getting this error returned:

ERROR: The multi-part identifier "WENS.dbo.SUBSCRIPTION.lat" could not be bound. Error Code: 4104

Is this because it is seeing a number of records that match the address?

Any help would be greatly appreciated! Thanks so much!



No comments:

Post a Comment