Home > Archive > Microsoft SQL Server forum > September 2005 > bcp header









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author bcp header
Patrik

2005-09-20, 11:23 am

Is there any way of including headers when we export a table using bcp
? Can't find the argument in bcp utility books online ?

Thanks for the help

Erland Sommarskog

2005-09-20, 8:23 pm

Patrik (patrik.maheux@umontreal.ca) writes:
> Is there any way of including headers when we export a table using bcp
> ? Can't find the argument in bcp utility books online ?


BCP does not unfortunately not support headers very well. If they can
be molded into the format of the rest of the file, you can sneak by.

Here are some examples:

value1,value2,value3

12,23,234

This is easy, use the -F option to start on row 2. Here is a tricker one:

value1,value2,value3

"text",12,"more test"

For this format you need a format file anyway for the data. This format
file will specify that each record begins with an empty column with " as
terminator. The result is that the header slips into that empty column
for the first row. You should not use -F.

Here is a dead end:

value1,value2,value3

12,"my text",12

I can't find a way to bulk-load this file, because the header does not
match the format of the data rows, and you can hide it an empty column.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com