Cross-server SQL

Boris Callens picture Boris Callens · Sep 16, 2008 · Viewed 51.9k times · Source

I want to port data from one server's database to another server's database. The databases are both on a different mssql 2005 server. Replication is probably not an option since the destination database is generated from scratch on a [time interval] basis.

Preferebly I would do something like

insert *
from db1/table1
into db2/table2
where rule1 = true

It's obvious that connection credentials would go in somehwere in this script.

Answer

Matthew Pelser picture Matthew Pelser · Sep 16, 2008

I think what you want to do is create a linked server as per this msdn article. You would then select using a 4 part object name eg:

Select * From ServerName.DbName.SchemaName.TableName