title: How to INSERT INTO table column with string/variable
body: <p>This is the data I have pulled from powershell and inserted it into a #temptable:</p>
  
  <pre><code>Name                   : SULESRKMA
  Location               : Leisure Services - Technology Services
  Shared                 : False
  ShareName              : 
  JobCountSinceLastReset : 0
  PrinterState           : 131072
  Status                 : Degraded
  Network                : False
  </code></pre>
  
  <p>I'm while looping through the data and have stripped the values from the identifiers.  I'd like to use these identifiers to insert the values into a table  with identical Column names to the identifiers.  So for example, I have a variable called @identifier = "Name" and a temp table #printers with a column name of Name.  I'd like to do something like:</p>
  
  <pre><code>SELECT --select statement
  INSERT INTO #printers(@identifier)
  </code></pre>
  
  <p>But This doesn't seem to work, unsurprisingly.  Is there a way to accomplish this?  (The @identifier variable will be changing to the other identifiers in the data throughout the course of the while loop.)</p>
  
  <p>Any alternate suggestions that don't even involve using this sort of method are welcome.  My ultimate goal is just to get this data as a row into a table.</p>
  
  <p>(I'm currently using Microsoft SQL Server Management Studio if that matters)</p>