Pivots with dynamic columns in SQL Server
I am working on an SQL Query using pvots with dynamic columns in SQL Server (T-sql). Rather than submitting my lengthy query, I’m illustrating my problem with a simplified model. I create 2 tables: Table1 and Table2 and populate them with a few entries as follows: Table1: Col_ID1...............Col_Name 1.........................Jan-11 2.........................Feb-11 3.........................Mar-11 Table2: Col_ID2......Account.....AccountName......Amount 1...............121...........Electricity............10000 2...............121...........Electricity............20000 3...............121...