﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by bapat_amit  / Copy Data Into Multi-Tenancy Database For Customer / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 00:23:50 GMT</lastBuildDate><ttl>20</ttl><item><title>Copy Data Into Multi-Tenancy Database For Customer</title><link>http://www.sqlservercentral.com/Forums/Topic1399721-1039-1.aspx</link><description>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 TenancyId2.  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 tablesI'm wanting to hear if there's any easy way of automating steps 3 &amp; 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.</description><pubDate>Sat, 22 Dec 2012 19:57:33 GMT</pubDate><dc:creator>Chris Clarke-296861</dc:creator></item></channel></rss>