SQL Server Performance Forum – Threads Archive
Include column names in export table –> textfile
Hi! In a DTS package I simply reads data from a table to a txt-file. But I haven´t figured out how to include the column-names in the exported file… Example how it looks like todaydata1;data2;data3;
data1;data2;data3;
data1;data2;data3; Example how i want it to look like
column1;column2;column3;
data1;data2;data3;
data1;data2;data3;
data1;data2;data3; Have a great life!
/Erik
If all the columns are of varchar datatype then Select ‘column1′ as col1,’column2′ as col2,’column3’ as col3
Union All
Select col1,col2,col3 from yourTable Madhivanan Failing to plan is Planning to fail
CREATE VIEW dbo.dummy
AS
Select ‘column1′ as col1,’column2′ as col2,’column3’ as col3, 0 AS SeqNum
Union All
Select col1,col2,col3, 1 AS SeqNum from yourTable The datasource for DTS might look like
SELECT … FROM dbo.dummy ORDER BY SeqNum That way you can be sure, that the column headings appear on top. —
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs
cheers for the help guys!<br />sometimes the easiest are the best way to do it, right <img src=’/community/emoticons/emotion-1.gif’ alt=’
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
And you need to make sure that all columns are of varchar datatpye. Otherwise you need to convert them to be of varchar Madhivanan Failing to plan is Planning to fail
Hi Erik – there is an easier way <img src=’/community/emoticons/emotion-1.gif’ alt=’
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
Hi Bennie !!
Ha.. I knew it had to be something like that but i thought that button had another meaning.. cheers, have a good day! /erik
If you dont use DTS, then query is the only way [<img src=’/community/emoticons/emotion-1.gif’ alt=’
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
Learn something new each day. Actually I’m glad not having to deal with DTS at all. [<img src=’/community/emoticons/emotion-1.gif’ alt=’
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
]]>