title: A Little PIVOT Table Help Please
body: <p>I am having some serious troubles getting this PIVOT table in TSQL to work properly.</p>
  
  <p>Here is some sample code to reproduce the source table...</p>
  
  <pre><code>Declare @MyAssigneeTable table (
                              VDayID int, 
                              VDate datetime, 
                              StartTime varchar(100), 
                              EndTime varchar(100),
                              PositionID int,
                              RoomID int,
                              RoomDesc varchar(100),
                              Position varchar(100),
                              SortOrder int,
                              Assignee varchar(100)
                          )
  
  
  
  INSERT INTO @MyAssigneeTable VALUES (2264, '2013-10-23', '7 AM','12 PM',13,150,'Room 1','Position 1',99,'')
  INSERT INTO @MyAssigneeTable VALUES (2264, '2013-10-23', '7 AM','12 PM',14,150,'Room 1','Position 2',99,'Matt')
  INSERT INTO @MyAssigneeTable VALUES (2264, '2013-10-23', '7 AM','12 PM',15,150,'Room 1','Position 3',99,'Kevin')
  INSERT INTO @MyAssigneeTable VALUES (2265, '2013-10-24', '7 AM','12 PM',13,150,'Room 1','Position 1',99,'')
  INSERT INTO @MyAssigneeTable VALUES (2265, '2013-10-24', '7 AM','12 PM',14,150,'Room 1','Position 2',99,'Amber')
  INSERT INTO @MyAssigneeTable VALUES (2265, '2013-10-24', '7 AM','12 PM',15,150,'Room 1','Position 3',99,'Lawrence')
  INSERT INTO @MyAssigneeTable VALUES (2266, '2013-10-25', '7 AM','12 PM',13,150,'Room 1','Position 1',99,'Chad')
  INSERT INTO @MyAssigneeTable VALUES (2266, '2013-10-25', '7 AM','12 PM',14,150,'Room 1','Position 2',99,'Kevin')
  INSERT INTO @MyAssigneeTable VALUES (2266, '2013-10-25', '7 AM','12 PM',16,150,'Room 1','Position 3',99,'')
  
  Select * from @MyAssigneeTable
  </code></pre>
  
  <p>I think that I want to do some sort of PIVOT but I cannot get the desired output. In this below desired table script, I was needing the column names to be driven from distinct dates, the position column rows to be distinct values, and the cell intersecting the row and column to be the assignee. But this is too complex for me to figure out. Can this even be done? Here is a DDL to recreate the desired output.</p>
  
  <pre><code>Declare @MyDesiredTable table (
                              Position varchar(200), 
                              [2013-10-23] varchar(100), 
                              [2013-10-24] varchar(100), 
                              [2013-10-25] varchar(100)
                           )
  
  INSERT INTO @MyDesiredTable VALUES('Room 1 / Position 1','','','Chad')
  INSERT INTO @MyDesiredTable VALUES('Room 1 / Position 2','Matt','Amber','Kevin')
  INSERT INTO @MyDesiredTable VALUES('Room 1 / Position 3','Kevin','Lawrence','')
  
  Select * from @MyDesiredTable
  </code></pre>
  
  <p>Can anyone help me with this?</p>
  
  <p>Thank you very much for your assistance!!</p>