SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
wittr
wittr
SSC-Enthusiastic
SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)SSC-Enthusiastic (188 reputation)

Group: General Forum Members
Points: 188 Visits: 44
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search