Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 bcp output

Author  Topic 

kmslick
Starting Member

6 Posts

Posted - 2009-01-15 : 17:06:56
Can anyone tell me how to include the field headers in an output file?

I'm using:
bcp DB.dbo.AuditExportGL20000 out c:\bcp\test.txt -c -t"|" -T -S ' + @@servername

This works fine but I need the first row of the output file to be the table column names.

revdnrdy
Posting Yak Master

220 Posts

Posted - 2009-01-15 : 17:25:43
Well here is a link that I used to do that. What you will need to do is BCP out of a view.

[url]http://www.sql-server-performance.com/tips/bcp_p1.aspx[/url]

Here is a another example (but a little more complicated). It is from Tara's blog.
[url]http://weblogs.sqlteam.com/mladenp/archive/2006/07/25/10771.aspx[/url]

Hope that helps you on your sql journey...

r&r
Go to Top of Page

kmslick
Starting Member

6 Posts

Posted - 2009-01-15 : 18:33:26
Thanks!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-15 : 18:44:18
That's from Spirit1's blog (Mladen), not mine.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -