sql - Can I do a INSERT using select from another DB with the same table name -


i have person table (sqlserver 2008r2) , using .vbs , .bat files sync data table called person in database a database b.

note - db names different table names same. because peson table has 137 fields looking way write both insert , update statement. how can thsi without listing 137 fields?

  1. at moment connect database a , populate recordset called rs people table records.
  2. then loop through rs , query people table in database b
  3. if found update people table in database b people table record database a
  4. if not found insert people record database a people table on database b

now nice , easy since has 137 fields not want write massive update , insert statements. have option such as:

the table structures identical between people on database a , people on database b recordset obtained in step 1 above using 1 one db connection , query in step 2 using separate db connection different db instance on different server.

help.

you can using qualified name.

insert database1.dbo.person (columns) select (columns) database2.dbo.person 

also there others way pump data database can take on mssms got tool kind of thing. select 1 database , right button mouse open import/export wizard. can take on replication, bulk copy, service broker, etc...


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -