udapte query across 2 db's

  • I have a query that has to update a table in DB1 with criteria (where clause) from DB2.tablename. I keep getting syntax errors with my query but nothing is helping me. I know this is simple but I can't quite get it.

    UPDATE mytable

    SET field1 = db2.tablename.field1

    where db2.tablename.field2 = 'US_CITIES'

    and state_county_fips_cd not like '02%'

    and state_county_fips_cd not like '15%'

  • update U

    set <your fields go here>

    from TableToUpdate U

    join TableInOtherDatabase O

    on U.KeyField = o.KeyField

  • Nice one Don, did'nt know could do it that way. I always did

    update TableToUpdate

    set <your fields go here>

    from TableToUpdate u

    join TableInOtherDatabase o

    on u.KeyField = o.KeyField

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply