title: Sql query to update table based on other tables
body: <p>I have table structre like this:</p>
  
  <p>Table <code>MainTable</code></p>
  
  <p>Columns: </p>
  
  <pre><code>Id INT, 
  TableName Varchar(50),
  StartValue VARCHAR(50) 
  </code></pre>
  
  <p>Here TableName column have names of all the tables present in the database</p>
  
  <p>Now I need to update "StartValue" column in <code>MainTable</code> from corresponding tables. Any idea how to achieve this?</p>
  
  <p>Example </p>
  
  <p><code>MainTable</code></p>
  
  <pre><code>Id TableName StartValue
  ----------------------
  1  table1      NULL  
  2  Table2     Null
  </code></pre>
  
  <p>I need to update <code>StartValue</code> column of <code>MainTable</code> by getting top 1 value from table name present in the tables</p>
  
  <p>Means record 1 will get first value from table1 and record 2 will get first value from table2</p>
  
  <p>Any idea how to achieve this?</p>