title: SQL Function Get Column By Reference
body: <p>Let's say there are 3 tables: Genders, Countries and Users. Users has among others a column named Gender and also a column named Country.</p>
  
  <p>I want to add a new entry to Users and select one of the columns Male/Female {M, F} and a country from the rows of Countries dynamically just for testing purposes.</p>
  
  <pre><code>insert into dbo.[Users] (Gender, UserName, Country)
    select Genders.Male, 'newbie', Countries.(the one which matches column CountryId) FROM Genders, Countries
  </code></pre>
  
  <p>I want to achieve this: <strong>'M', 'newbie'</strong>, MyCountry </p>
  
  <p>After applying the suggestion from 'zip' I get the result <strong><em>2 rows affected</em></strong>, same number as the external tables I'm referencing. The Query added 2 rows, <strong>so I guess I am missing the WHERE conditions.</strong></p>
  
  <p>The Genders Table is meant as a Property and will have only one row that I manually added.</p>
  
  <pre><code>Table Genders; 1 row
  Male : uniqueidentifier
  Female : uniqueidentifier
  </code></pre>
  
  <p>Countries is a table with many rows, so I want to select one matching the criteria of one of it's column values, say the value of column CountryId.</p>