SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Create Pivot , Exporting the result into flat file with Column Header


Create Pivot , Exporting the result into flat file with Column Header

Author
Message
BI_NewBie
BI_NewBie
SSChasing Mays
SSChasing Mays (606 reputation)SSChasing Mays (606 reputation)SSChasing Mays (606 reputation)SSChasing Mays (606 reputation)SSChasing Mays (606 reputation)SSChasing Mays (606 reputation)SSChasing Mays (606 reputation)SSChasing Mays (606 reputation)

Group: General Forum Members
Points: 606 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.


Thanks

Regards,
Deepika
siggemannen
siggemannen
Mr or Mrs. 500
Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)Mr or Mrs. 500 (563 reputation)

Group: General Forum Members
Points: 563 Visits: 380
Why not have a UNION of two selects?
One that selects column names for the first row and another that selects actual data?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search