title: T-SQL PIVOT: One row to column name and the other to value
body: <p>I am using SQL Server 2008.</p>
  
  <p>I have two tables </p>
  
  <ol>
  <li><code>User</code> (<code>UserID, Name, Link</code>)</li>
  <li><code>UserNotes</code> (<code>NoteID, UserID, Title, Description</code>)</li>
  </ol>
  
  <p>This is the sample data structure.</p>
  
  <pre><code>INSERT INTO [User]
      ([UserID], [Name], [Link])
  VALUES
      (1, 'John', 'L1'),
      (2, 'Steve', 'L234');
  
  INSERT INTO [UserNotes]
      ([NoteID], [UserID], [Title], [Description])
  VALUES
      (1, 1, 'AboutJohn', 'This is about john'),
      (2, 1, 'John Work', 'This is where John work'),
      (3, 1, 'John Education', 'This is the uni where John go'),
      (4, 2, 'Steve Note1', 'Des1 about Steve'),
      (5, 2, 'Steve Note2', 'Des2 about Steve');
  </code></pre>
  
  <p>Here is <a href="http://sqlfiddle.com/#!3/4f77d" rel="noreferrer">SQL Fiddle</a></p>
  
  <p>I want to create view (<code>User_view</code>) as follows and when I execute this command the output should be as follows.</p>
  
  <pre><code>SELECT * FROM User_view WHERE UserID IN (1)
  
  UserID    Name   AboutJOhn              JohnWork                  JohnEducation
  1         John   This is about john     This is where Johnwork    This is the uni where John go
  </code></pre>
  
  <p><code>Title</code> column of child table should become column name and <code>Description</code> should become value of that column and we do not know how many rows we will have. I am aware of the issue when we select two users and which name to use column name. In that case we can use (Note1, Note2, Note3, etc for multiple User), otherwise use title field as Column name. Is it possible to do so? Cheers!</p>