title: T-SQL: Creating a temp Table/ table Variable with Flexible structure
body: <p>I am working on a reporting project based in SQL but I have restricted access to the DB; I can only make SELECT Queries and insert the data I retrieve into temp Tables/table variables. I cannot create/execute stored procedures or any sort of functions. </p>
  
  <p>The query I am running is meant to pool together all Engineers and the different key skills that they have so that we can later on see what Skills each engineer has or which Engineers fall under a certain skill. </p>
  
  <p>To this end, I am trying to create a table variable/temp table with a flexible structure, a structure based on previously obtained values in the same query.  </p>
  
  <p>For E.g.</p>
  
  <p>1st Output:
  Adam
  Brad
  Julio
  Martinez</p>
  
  <p>2nd Output (Skill separated by white space): 
  VOIP
  TTS
  DBA
  Exchange
  Server</p>
  
  <p>Create temp table/table variable that uses 1st output as rows and 2nd output as columns or vice versa. I will then populate this new table according to different values on the main DB. </p>
  
  <p>Please advise how this can be done, or provide any other solution to this problem.
  Thank you</p>