Possible Duplicate:
update one table with data from another
Extreme SQL noob here. I have two databases (Database1, Database2). Each db has the same tables. I want to update TableA in Database2 with the data in TableA from Database1 (Database1,TableA -> Database2,TableA).
What’s the best way to do this?
Like this, assuming you use a
dboschema.You might want to
truncate Database2.dbo.TableAfirst if the incoming data should overwrite the old or you are using an identity field.If you need the ids to be the exact same across the tables, you should disable the identity property on
Database2.dbo.Tablebefore running the script and re-enable it afterward.