title: Combine Static Columns with Dynamic Columns in SQL SERVER 2008
body: <p>I have a table SchoolStudent with three columns and the following values</p>
  
  <p><img src="https://i.stack.imgur.com/Iw561.png" alt="enter image description here"></p>
  
  <p>Now, for a student we can have dynamic columns which are stored in a table with values as:</p>
  
  <p><img src="https://i.stack.imgur.com/pDi1B.png" alt="enter image description here"></p>
  
  <p>I want a query where i can club static fields as well as dynamic fields in a single SQL Query. I tried using Pivot but was not successful. Please suggest on how to accomplish this. I am basically doing it so that on frontend i have one resultset which can be searched thru.</p>
  
  <p>So query should be:</p>
  
  <pre><code>Select 
      StudentID, FirstName, Address, MotherName, 
      MotherEmail, MotherOccupation, Mother Salary, 
      FacebookProfileName, VehicleRegNo 
  from SchoolStudent 
  Inner Join 
      (Logic to convert rows to columns)
  </code></pre>