Dynamic Pivot Table for status on particular days in SQL

I've seen parts of it done but trying to get it all in one thing. Creating a single output table from two seperate ones.

tblMeetingTime one
-----------------
MeetingID   GroupID    MeetingTime
1           21          11/5/2011 8:30
2           21          11/9/2011 14:30
3           21          11/15/2011 8:30
4           23          11/5/2011 13:00
.           .           .
.           .           .

tblPeople
------------------------
GroupID     PersonID
21          3463  
21          3563
23          3245
.           .

tblRecordAttendance
--------------------------------
MeetingID    PeronID      Status
1            3463         A
1            3563         NULL
2            3463         N
2            3563         N
.            .            .

If needed to I can redo some of the tables, but that is how the raw data is brought in. I am hoping to have something like

 Person     11/5/2011 8:30 AM      11/9/2011 2:30 PM      ...      
 --------------------------------------------------- 
 3463        A                      N
 3563                               N
 .
 .
 .

I have a good idea of how to do it in straight C#, but it would take a good amount of opening, repulling and organizing the data and hoping to come up with some sort of SQL Pivot to do it all, particularly with new MeetingTimes being added for each group.

Thanks,

Wade


ANSWERS:


SQL Server requires that all column values are pre-defined for the PIVOT operator. The only way to do it in a SP would be to first query all the column values, then create a PIVOT command as a string and pass it to sp_executesql to get your answer.

I would suggest using SQL Server Reporting Services. You can use the ReportViewer control in client-only mode and don't even need the server components installed. Then, you can create a matrix report that calculates what you need.

Don't let MSDN scare you off. It's really as simple as installing the control on your computer (and the Web server); Visual Studio will then have a report designer plug-in that opens whenever you open an RDLC file. It also adds a "Report" option to the "Add New..." menu.

You could do it manually in C# as well. You don't need to re-query. Whether you leverage the ReportViewer control or do it yourself, you just pull the listing from the procedure as a big stack of person/meeting rows. If you're using .NET 4, then LINQ to Objects will make it a snap to process in plain C# while building your HTML table.



 MORE:


 ? Dynamic SQL Server Pivot Table
 ? Join/Pivot items with EAV table
 ? Dynamic Pivot table error
 ? SQL Pivot Query with Dynamic Columns
 ? SQL Pivot Query with Dynamic Columns
 ? SQL Pivot Query with Dynamic Columns
 ? T-SQL Pivot? Possibility of creating table columns from row values
 ? SQL Server : Querying Multiple Rows, Returning In One
 ? Need to pivot or crosstab a table but not in the conventional way. please
 ? How to write a query which will result in the following format?