I have a bunch of queries that I would like to dump directly to CSV. Everything works great EXCEPT there is no option to include the column names from the query (not necessarily the same as the underlying table column names). From looking around, it appears that doing a union with the column names is the only way to do what I want. My problem is:
How can I programmatically get the column names from my query?
The column names are not the same as the underlying table, so I cannot use the Information Schema.
Please let me know if you have any ideas or a better way to accomplish what I'm doing!
Thanks!