Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Create Pivot , Exporting the result into flat file with Column Header Expand / Collapse
Posted Friday, October 4, 2013 4:56 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, September 8, 2016 6:47 AM
Points: 200, Visits: 157
Dear All,

I am trying to create pivot of some table.

some how i managed to create pivot. Now i am exporting the resultant data into flat file. while doing so i am unable to retrieve column headers since while creating pivot column headers are dynamic.

I am using BCP command to export the data into txt.

1. Select * from Table : giving me only data not column
2. SELECT [Column 1], [Column 2].... ---> I cant use this query since my column are dynamic and that depends on the data i have in my table.

How to get dynamic column headers into flat file????

Please help me with this.


Post #1501526
Posted Friday, October 11, 2013 4:07 PM


Group: General Forum Members
Last Login: Wednesday, October 12, 2016 12:27 PM
Points: 137, Visits: 364
Why not have a UNION of two selects?
One that selects column names for the first row and another that selects actual data?
Post #1504164
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse