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

Export with Headers Expand / Collapse
Author
Message
Posted Thursday, November 18, 2010 2:23 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 7:21 AM
Points: 33,279, Visits: 15,450
How can you export data from a query, using bcp, SQLCMD, etc. and include the column headers at the top? The export would be CSV or other delimited text file.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1023170
Posted Thursday, November 18, 2010 8:13 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:14 PM
Points: 37,107, Visits: 31,665
Steve Jones - SSC Editor (11/18/2010)
How can you export data from a query, using bcp, SQLCMD, etc. and include the column headers at the top? The export would be CSV or other delimited text file.


Unless someone else has an absolute need to write this one, I'll be happy to take this one on. It won't include anything about SSIS, though. Might be better if that were a separate article, anyway.

Lemme know.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1023265
Posted Friday, November 26, 2010 1:59 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 7:21 AM
Points: 33,279, Visits: 15,450
It would be good to have an SSIS and non/SSIS version






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1026879
Posted Friday, November 26, 2010 4:08 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:14 PM
Points: 37,107, Visits: 31,665
Since I don't actually know how to spell "SSIS", I'll take the non-SSIS version.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1026903
Posted Wednesday, December 1, 2010 3:04 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 12:33 PM
Points: 1,716, Visits: 3,380
I doubt whether a complete article is needed for SSIS. The connection managers for Excel and flat files presents a check box to determine whether you want the first row to be column names.

jg
Post #1028972
Posted Thursday, December 2, 2010 6:27 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 6:38 AM
Points: 15,739, Visits: 28,147
For the non-SSIS version, what language are you using? Because if it's not PowerShell, I might want to do one using PowerShell.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1029200
Posted Thursday, December 2, 2010 10:16 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:14 PM
Points: 37,107, Visits: 31,665
Grant Fritchey (12/2/2010)
For the non-SSIS version, what language are you using? Because if it's not PowerShell, I might want to do one using PowerShell.


Steve asked for "using bcp, SQLCMD", but I think one on PowerShell should come out first. And, since I don't actually know how to spell "PowerShell", I'd be tickled to see a "Grant Fritchey" article on such a thing. I can write on something else.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1029639
Posted Thursday, December 2, 2010 10:36 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 8:11 PM
Points: 6,604, Visits: 8,910
Grant Fritchey (12/2/2010)
For the non-SSIS version, what language are you using? Because if it's not PowerShell, I might want to do one using PowerShell.


That would be quite cool!


Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
Post #1029648
Posted Friday, December 3, 2010 5:43 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 6:38 AM
Points: 15,739, Visits: 28,147
Jeff Moden (12/2/2010)
Grant Fritchey (12/2/2010)
For the non-SSIS version, what language are you using? Because if it's not PowerShell, I might want to do one using PowerShell.


Steve asked for "using bcp, SQLCMD", but I think one on PowerShell should come out first. And, since I don't actually know how to spell "PowerShell", I'd be tickled to see a "Grant Fritchey" article on such a thing. I can write on something else.


Let's see what the boss says. I don't know why you couldn't do both.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1029794
Posted Friday, December 3, 2010 6:35 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 10:22 AM
Points: 3,433, Visits: 14,430
gmby (12/1/2010)
I doubt whether a complete article is needed for SSIS. The connection managers for Excel and flat files presents a check box to determine whether you want the first row to be column names.

jg


The above just means you don't know what you can do with SSIS; I have almost 1,000 lines of code using SSIS. You can turn header on and off, encapsulations on and off and delimiter agnostic using configurations.


Kind regards,
Gift Peddie
Post #1029823
Posted Friday, December 3, 2010 8:59 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 7:21 AM
Points: 33,279, Visits: 15,450
Be good to have one in Powershell, and while we're at it, anyone want SQLAzure?






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1029938
Posted Friday, December 3, 2010 9:13 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 6:38 AM
Points: 15,739, Visits: 28,147
Steve Jones - SSC Editor (12/3/2010)
Be good to have one in Powershell, and while we're at it, anyone want SQLAzure?


Right, I'll do one in PowerShell, but no promises on deliver time. Jeff "Jack Rabbit" Moden should go ahead with his. I'll be along shortly.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1029957
Posted Friday, December 3, 2010 9:21 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 7:21 AM
Points: 33,279, Visits: 15,450
No hurry on any of these.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1029966
Posted Sunday, February 10, 2013 10:24 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:14 PM
Points: 37,107, Visits: 31,665
Steve Jones - SSC Editor (12/3/2010)
No hurry on any of these.


I guess that's a good thing. Grant, did you ever get yours done? I know I'm way overdue on this.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1418205
Posted Monday, February 11, 2013 4:36 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 6:38 AM
Points: 15,739, Visits: 28,147
Jeff Moden (2/10/2013)
Steve Jones - SSC Editor (12/3/2010)
No hurry on any of these.


I guess that's a good thing. Grant, did you ever get yours done? I know I'm way overdue on this.


Forgot all about this. I'll add it to my queue.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1418313
Posted Thursday, September 5, 2013 8:06 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:14 PM
Points: 37,107, Visits: 31,665
Damn. I forgot all about this. I'll get started early next week. According to what Steve asked for in his OP, I'm thinking that I might be able to pull it off as a Spackle article.

Grant, what are you going to call yours? If we do it right, Steve can run them back to back or maybe even on the same day. Be really cool to have them similarly named especially if we consider what people might look for in a Google search on the subject.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1492023
Posted Friday, September 6, 2013 4:03 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 6:38 AM
Points: 15,739, Visits: 28,147
Jeff Moden (9/5/2013)
Damn. I forgot all about this. I'll get started early next week. According to what Steve asked for in his OP, I'm thinking that I might be able to pull it off as a Spackle article.

Grant, what are you going to call yours? If we do it right, Steve can run them back to back or maybe even on the same day. Be really cool to have them similarly named especially if we consider what people might look for in a Google search on the subject.


Ha! It's on my queue. Along with 20 other things. I'll see what I can do to bump it up. I'm easy on the title. Just say 'With X' at the end and we'll substitute PowersShell.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1492137
Posted Friday, January 31, 2014 9:30 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 7:21 AM
Points: 33,279, Visits: 15,450
Bump

Export data from a table(view/query) with Powershell. Include headers for easy reading.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1536852
Posted Monday, April 7, 2014 10:04 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, September 14, 2014 9:24 PM
Points: 162, Visits: 171
Submitted.

----------------------------------------------------------------------------------------------
Microsoft Certified Solution Master: Data Platform, Microsoft Certified Trainer
Email: Louis.Li@rrlminc.com | Blog | LinkedIn
Post #1559347
Posted Tuesday, April 8, 2014 1:38 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 7:21 AM
Points: 33,279, Visits: 15,450
Louis Li (4/7/2014)
Submitted.


Louis, I see a script from you and that's good, but I'm still looking for an article with explanation of how to do this and how it works in a little more detail.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1559683
Posted Tuesday, April 8, 2014 1:48 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, September 14, 2014 9:24 PM
Points: 162, Visits: 171
Sure, Steve.

----------------------------------------------------------------------------------------------
Microsoft Certified Solution Master: Data Platform, Microsoft Certified Trainer
Email: Louis.Li@rrlminc.com | Blog | LinkedIn
Post #1559687
Posted Wednesday, April 23, 2014 4:08 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, September 14, 2014 9:24 PM
Points: 162, Visits: 171
Steve Jones - SSC Editor (4/8/2014)
Louis Li (4/7/2014)
Submitted.


Louis, I see a script from you and that's good, but I'm still looking for an article with explanation of how to do this and how it works in a little more detail.


Submitted, Steve.


----------------------------------------------------------------------------------------------
Microsoft Certified Solution Master: Data Platform, Microsoft Certified Trainer
Email: Louis.Li@rrlminc.com | Blog | LinkedIn
Post #1564471
Posted Thursday, April 24, 2014 10:51 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 7:21 AM
Points: 33,279, Visits: 15,450
Thanks, I see it and I'll review it as soon as I can.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1564773
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse