title: Convert tree table from source database to destination database using SSIS
body: <p>I use <code>SSIS</code> for convert data from old database to new database. I use below solution for convert tree source table to tree target table.</p>
  <p>FIRST: convert all data from source to destination</p>
  <p>Second: set <code>ParentID</code> column in destination table according to source `ParentID' column in source table.</p>
  <p>Source table structure is :</p>
  <pre><code>TbSource (ID int, ParentID int, Name NVarchar(50))
  </code></pre>
  <p>Destination table structure is :</p>
  <pre><code>TbDestination (ID int,  ParentID int, Name NVarChar(50), HID Hierarchy, OldID int)
  </code></pre>
  <ul>
  <li>Step 1 : I convert all data from <code>TbSource</code> to <code>TbDestination</code> with NULL value for ParentID.</li>
  <li>Step 2 : Update <code>ParentID</code> of <code>TbDestination</code> according to <code>OldID</code> column and <code>TbSource</code> table.</li>
  </ul>
  <p>I have trigger on TbDestination for calculate HID Column. <a href="https://stackoverflow.com/q/11381537/1407421">Can see hear</a>.</p>
  <p>I look up for better way to convert data that convert in one step.</p>
  <p>Source Database and Destination Database are <code>SQL Server 2008 R2</code></p>