title: Using SQL Server stored procedure to match column name to variable
body: <p>UPDATED.</p>
  
  <p>I made modifications to the Store Procedure:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[Get_Labor_Rates_By_CompanyID]
  --Get_Labor_Rates_By_CompanyID '5116' ,'FOREMAN-REGULAR TIME (8hr Day Monday-Friday)* (HR)'
  
  @CompanyID bigint,
  @Labor_Type nvarchar(200)
  
  AS
  BEGIN
  
  Select COLUMN_NAME from 
  [Emerald_Data].INFORMATION_SCHEMA.COLUMNS
  Where TABLE_NAME= N'tbl_Client_List_Pricing' and 
  COLUMN_NAME=@Labor_Type
  
  Select * from tbl_Client_List_Pricing
  where [CompanyNum]= @CompanyID
  
  END
  </code></pre>
  
  <p>After Running I have the following two tables from the select statements:
  <a href="https://i.stack.imgur.com/fjr4Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fjr4Z.png" alt="enter image description here"></a></p>
  
  <p>I need to combine the two statements so the top COLUMN_NAME result filters the second Select to only show that Column and it's data for the Client Alston Construction. The Top COLUMN_NAME also exists in the bottom select as a COLUMN_NAME</p>
  
  <p>The End Result Should look like:</p>
  
  <pre><code>Client                |   FOREMAN-REGULAR TIME(8hr Day Monday-Friday)* (HR)
  ----------------------------------------------------------------------------
  Alston Construction   |   45
  </code></pre>