I have a table that looks like this:
Month Site Val
2009-12 Microsoft 10
2009-11 Microsoft 12
2009-10 Microsoft 13
2009-12 Google 20
2009-11 Google 21
2009-10 Google 22
And I want to get a 2-dimension table that gives me the "Val" for each site's month, like:
Month Microsoft Google
2009-12 10 20
2009-11 12 21
2009-10 13 22
But the catch is, I don't know all the possible values that can be in "Site". If a new site appears, I want to automatically get a new column in my resulting table.
All the code samples I saw that could do this required me to hardcode "Microsoft and Google" in the query text.
I saw one that didn't, but it was basically faking it by listing the Sites and generating a query on the fly (concatting a string) that had those column names in it.
Isn't there a way to get SQL Server 2008 to do this without a hack like that?
NOTE: I need to be able to run this as a query that I send from ASP.Net, I can't do stored procedures or other stuff like that.
Thanks!
Daniel