title: How to Back up and restore a single table with foreign keys using SQL Server
body: <p>I have a table in a database:</p>
  
  <ul>
  <li>MyTable</li>
  </ul>
  
  <p>Other have foreign key constraints to MyTable's Id column:</p>
  
  <ul>
  <li>MyOtherTable1</li>
  <li>MyOtherTable2</li>
  </ul>
  
  <p>I need to backup MyTable as is.</p>
  
  <p>The task I am going to do is a data conversion. While the data conversion works in QA, our change control requires that we have to have a rollback process in place. I don't plan to actually have to restore the table as is, but I have to prove that I can before change control lets me make the change.</p>
  
  <p>The system is a live order system. I cannot restore the whole database because many orders will go through between the time the change is made and when I will know if I have to restore.</p>
  
  <p>I already figured out how to backup the table. </p>
  
  <pre><code>SELECT * INTO MyTable_Bak FROM MyTable;
  </code></pre>
  
  <p>However, restoring the table is not working. I cannot do this:</p>
  
  <pre><code>DELETE FROM MyTable
  SELECT * INTO MyTable FROM MyTable_Bak;
  </code></pre>
  
  <p>The above fails because of foreign key constraints. </p>
  
  <p>I am not looking for a $oftware. I know Red Gate and other tools could do this.</p>
  
  <p>The tools available to me are:</p>
  
  <ul>
  <li>SQL Management Studio</li>
  <li>Admin privileges to the database</li>
  </ul>
  
  <p>Additional Requirements</p>
  
  <ul>
  <li>The data in every column most be identical after the restore. Id,
  dates, etc.</li>
  <li>The table cannot be dropped</li>
  <li>Rows in MyOtherTable1 or MyOtherTable2 cannot be changed or deleted.</li>
  </ul>
  
  <p>Note: With this detailed of a question, I detected the smaller parts of this problem one by one as I wrote the question and solved each problem seperately. Do I keep the question and answer it myself or delete it? Since I found no similar question and answer, I will keep it.</p>