We are doing an import process from a source database to a destination database. We need to run these imports frequently in an automated fashion.
The source is on a separate server than the destination. Both are MS SQL 2008. We access the source using Linq2SQL and the destination using a custom Data Layer. We do not ever modify the source DB (though we do not restore it as read-only at present). However, right now when we run the import within a transactionScope, the entire transaction gets promoted to DTC because we access two DBs on separate servers.
If we were to make the source DB read-only, would it still do this?
Any other suggestions on how to avoid the DTC promotion in this scenario?
Follow-up questions to Remus' answer (thanks again):
Follow-up #1: My import routine is structured such that it imports records from the source and creates new records in the destination. Like this:
using(var scope = new TransactionScope())
{
// read some from source db using Linq2Sql
// transform source info
// update destination
// read some more from source db using Linq2Sql
// transform source info
// update destination
}
Are you saying to surround the Linq2Sql bits in a TransactionScope with RequiresNew? Or, I guess, sine I really do not care about transactions at the source, I could surround with TransactionScope with Suppress to that connection's inclusion in any transaction at all, right?
Follow-up #2:
When you say "open a second connection, even to the same Database" - I have read several variations on this:
- "second connection" == second instance of the Connection object even it exactly the same connectionstring
- "second connection" == connection to a separate Resource Manager and on SQL2005 and before this means same as 1 above, but on SQL2008 this means a separate instance (i.e. two DBs on the same instance do not get promoted)