title: Relational table copy with transformation in most generic way ( declarative rules and etc... ) - Microsoft sandpit
body: <p>I guess, it is quite common task.  There is a table A let's say in Visual Foxpro and needs to be transformed to table B in SQL Server 2008.
  Operation is going to be repetitive. Column names may be changed , some input columns dropped , column types may be changed ( string &lt;=> int ), some output columns generated ( GUID , identity ) . Also normalization may happen where input table results in 2 joined with pivot table - let's drop this case for simplicity     </p>
  
  <p>I know about SSIS existence , probably there are scripts which can do what I described ? </p>
  
  <p>I've already written C# program which reads XML ( snippet below ) and  does mapping and out key generation but just thought whether all that -  another wheel reinvention. </p>
  
  <pre><code>  &lt;Tables&gt;
      &lt;Table inTbl="A" outTbl="B"&gt;
        &lt;Keys&gt;
          &lt;Key name="it_pk" type="GUID"&gt;
        &lt;/Keys&gt;
        &lt;Mappings&gt;
          &lt;Column inCol="hxkey" outCol="it_tariff"  /&gt;
          &lt;Column inCol="txt" outCol="it_description" /&gt;
          &lt;Column inCol="uq1" outCol="it_uq1" /&gt;
          &lt;Column inCol="date1" outCol="it_startdate" /&gt;
          &lt;Column inCol="date2" outCol="it_stopdate" /&gt;
        &lt;/Mappings&gt;
      &lt;/Table&gt;
    &lt;/Tables&gt;
  </code></pre>