How to semi-automatically update SQL Azure databases from a master copy (some tables only)

  • Greetings.
    My scenario: We have an application hosted on Azure, using SQL Azure databases. There are multiple copies of the databases, one per client. We have a number of tables which can only be added or modified in our company's home copy of the database. As these tables are modified over time, we would like to see that the other copies of the database get updated to reflect the changes. It gets a little more complicated b/c some of these tables contain foreign key columns that point to items which will have different foreign keys on the remote databases.

    I have spent time reviewing the various options within SSMS, also various suggestions on the web, & I'm just not quite sure of how to proceed with this.

    My potential approach is:
    1. Run a T-SQL script to create a (temporary) new schema on our copy of the database, then copy two groups of tables into this new schema, to place everything I want to export into a single schema. The first group of tables are those that will completely replace their counterparts on the remote databases. The second group of tables are lookup tables which contain items that are referenced by foreign keys in the first group of tables, but for which the tables themselves are not going to be copied over; fortunately, this second group of tables do contain a unique column that IS consistent across all database copies, so I can use this to construct cross-reference lists.
    2. Run some sort of script that exports the above-created schema & contents into a file or package.
    3. Unpackage these contents on the remote database copies, as needed.
    4. Run a script on the remote SQL Azure database that first matches up the appropriate keys, to the values in the cross-reference tables (the 2nd set of tables from above.)  Use these cross-reference tables to revise the relevant foreign key columns in the 1st set of tables from the package. Then, drop any relevant constraints, delete from the relevant remote tables, & populate them using the data from the 1st set of tables from the package, recreate the constraints, & clean up.

    Since this process will be routinely performed by someone else, it needs to be almost-automated, i.e., it would be preferable if it could be achieved by just a few actions (script, command line, package, whatever), possibly one action for each step above.  Steps #1 & 4 above are simple T-SQL scripts. I'm having a difficult time finding anything that works nicely for step #2.  The combination of needing to select only data from a specified set of tables, then export this to a single file or package, with simply a single-step command, I'm just not finding a tool that can do this for me. Possibly, steps #1 & #2 above could even be a single step, with the right tool.

    I would appreciate any suggestions, or possibly, an alternative solution, seeing what my end-result needs are. 

    Thanks,
    Randy

Viewing 0 posts

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