Problem
You need to obtain data from one data source to process and store in another. You don't want your server-side-script to use two connection objects and be the slow middle-man between them, as in the diagram on the left.Solution
If both data sources are databases on the same MS SQL Server, it's a piece of cake to do optimally with just one connection object and pure T-SQL.Just do the following:
- Set up Security - Add the user of the destination database as a user of the source database with at least db_datareader access.
- Prefix foreign tables with Schema - In your SQL that writes to the destination-database, prefix all tables housed in the source(foreign)-database with their "fully qualified" position in the schema to indicate which database they reside in, as illustrated in the example below.
Example
Table tblSource is from of the ForeignDB database, but tblDestination is from the active database.insert into tblDestination (colA, colB)
select col1, col2
from [ForeignDB].dbo.tblSource
I think you'd find it boring since there's no Flash work, but you could come be a server database tech guy at my work!
ReplyDelete