SQL Server move data between databases

879 views Asked by At

We have a requirement where we will have to move data between different database instance on regular basis. (For e.g. some customers willing to pay more for the better performance). So this is not going to be one off.

The database tables has referential integrity. Is there a way in which this can be done without rewriting sql script (or some other method) every time we migrate customers data?

I came across this How to move data between multiple database's table while maintaining foreign-key relationships/referential integrity?. However it appears that we have write script every time we migrate data (please correct me if I misunderstood the answer on this thread).

Thanks

Edit:

  • Both servers are using SQL Server 2012 (same version). Its an Azure SQL Server database.
  • They are not necessarily linked (no firewall between them)
  • We are only transferring some data, not the whole database. This is only for certain customers who opted pay more.
  • The schema are exactly same in both databases.
2

There are 2 answers

2
Mahesh Jasti On

Have a look into Azure Data Sync. It is much more aligned with your requirements. But you may end up in having another SQL Azure DB to maintain a Hub. Azure data Sync follows hub-spoke pattern and will let you do all flexible directional syncs with a few minutes of syncing gap. It is more simple and can set it up very fast without any scripts and all as you wanted.

1
Joseph Idziorek On

Preyash - please see the documentation on the Split-Merge tool. The Split-Merge tool enables you do move data between databases, as you have described, based on a sharding key (e.g., customer ID). One modification that you will need for your application is to add a shard map (i.e., a database that understand the global state of which customers resides in which databases).