I am trying to setup one-way, transactional replication from SQL Server 2008 R2 to PostgreSQL 9.1. I'm trying out the PGNP OLE DB provider.
I can successfully create a subscription, and transactions are indeed replicated to the PG server. I am using sync_type = 'none' on the subscription, because it seems that otherwise, the schema, including SQL Server specific options (SET ANSI_NULLS ON, etc.) get sent to PostgreSQL, which screws it up.
This is fine, I can use SSIS and copy my entire database over, including data. My question is, how can I do this in a safe way? Because if I just run a SSIS package to export the data, then add the subscription, transactions could get lost.
E.g. SSIS exports data to PG. Row X is updated. Replication starts. In this case, row X's update wouldn't be in my manual sync, but replication started after. And I can't have replication running, because other errors could happen.
What's the proper procedure here?
I had several times a similar problem. The trick for this is to setup 2 Subscriptions
So here is the whole procedure:
Please note that while the Log Reader Agent is stopped the transactions on the Publisher will be stuck on the LOG of the Publisher. So take care to not let it go full. Step 5 ( copying the data ) can be pretty long, so configure a big enough log on the primary ( depending on the volume of transaction ).
By the way, if you put sync_type to 'automatic' the snapshost agent will generate a snapshot which will be properly synced also. Where's my bounty?
Try this article SQL Server Replication Crib Sheet