Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, January 31, 2014 4:49 AM
Points: 9, Visits: 41
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: Monday, October 13, 2014 12:06 AM
Points: 115, Visits: 277
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