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


Copy Data Into Multi-Tenancy Database For Customer


Copy Data Into Multi-Tenancy Database For Customer

Author
Message
Chris Clarke-296861
Chris Clarke-296861
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 115
We've an application running a multi-tenanted database where each tenancy is for a specific customer.
(This can't be uncommon nowadays ?)

I'm trying to work out how to deal with restoring the data for an individual customer (TenancyId) if/when they request it.

We've daily backups of the full database so it's a matter of;
1. Deleting all the data from the Live database with the TenancyId
2. Restoring a backup as a temporary database,
3. Pulling the data from the backup db with the TenancyId
4. And inserting the data into the Live db with IDENTITY_INSERT ON against the tables

I'm wanting to hear if there's any easy way of automating steps 3 & 4 ?

There are currently 41 tables to deal with and I don't want to have to code individual inserts for each table.

The trouble with backup restores is that they're rarely used, difficult to test in the Live environment and can be a disaster if they don't work flawlessly.

So I'd like a procedure that doesn't rely on code being changed each time a database table is changed.

The nearest I've seen to this is the sp_generate_inserts code by Narayana Vyas Kondreddi (kudos++) which will output SQL Insert statements for each table.

Is it possible to direct this output to a .sql file ?

Suggestions greatly appreciated.


Kindest Regards,

Chris Clarke

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