Importing Data from Excel into tables: Merge Replication

  • I have a reasonably simple Merge Replication setup (if such a thing exists) between a Publisher and a single Subscriber, both full SQL Server machines.

    The replication has been ticking over steadily for the last 2 years or so, and synchronization occurs every hour on the hour.

    Over the last couple of nights I have commenced a project to import additional data into half a dozen or so tables that are being replicated, from a series of Excel spreadsheets. Several hundred thousand rows of data from various spreadsheets need to be imported.

    I have used the SQL Server Import and Export wizard to import the data from the spreadsheets, and whilst this all works well, I noticed that the new records don't get included in the next synchronization.

    To get around this, I ran a script to exclude these 6 or so specific tables from replication, invalidating the snapshot in the process, re-added these articles into replication, created a new snapshot, and then the next synchronization worked. Whilst this method "works", a lot of time is spent waiting for snapshots to be created, and due to the large amount of data, synchronization to occur

    Is there a better way to import this data from an external source, so that I can avoid invalidating snapshots and so that only the new data needs to be synched?

    I need to perform a similar task for another client, so would like to be able to do it "the right way" for next time

  • I have found a much better way of doing this, just thought I'd add it to this post

    I am keeping my import process (importing from Excel sheets into SQL tables that are marked for replication, which all works fine) but after doing this I have found that I should run the following in a SQL query window:

    sp_addtabletocontents tablename

    If you synchronise after running that stored procedure all the new records get included as inserts and it appears all existing get added as updates, but ultimately there is no need to re-create a snapshot, saving me hours

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply