SQL Pivot Query with Dynamic Columns [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: T-SQL Pivot? Possibility of creating table columns from row values I've been searching in vain for too long now and have to admit defeat and ask for help, I'm trying to modify a pivot query to produce a dynamic query of results from a table with data like this: UserId PageViewed DateTimeStamp 1 Index.html 2011-12-01 13:55:01 1 FAQ.html 2011-12-01 13:58:53 1 ContactUs.html 2011-12-01 14:00:16 2 Index.html 2011-12