Re: Bulk Import with header in text file



(cbanks@xxxxxxxxxxxxxx) writes:
> I would appreciate some help on a procedure that I have. Using Bulk
> Insert, I would like to import records from a text file. The issue I
> have is the file contains a header - '1AMC_TO_Axiz' and a footer
> '1AMC_TO_Axiz2". Using a format file, I can get the import to work by
> editing the file and removing these two entries. Is there a way to
> setup the format file to skip these two entries? My file currently
> looks like this:
> 7.0
> 16
> 1 SQLCHAR 0 50 "|" 1 keyMemberNo
> 2 SQLCHAR 0 10 "|" 2 fldEffdate
> ................
> 16 SQLCHAR 0 10 "\r\n" 16 fldNewRecord

BCP is very squared, and there is no way to specify a footer or a header.
The one exception is when you can hide the header in the format somehow.
If the headers fits into the format, you can the FIRSTROW and LASTROW
options to skip them.


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Datatype-convertion in TSQL
    ... Can't find a code for datetime-conversion from nvarchar format DD/MM/YYYY ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: bulk inserting uniqueidentifier column
    ... I use in bulk insert a format file like this: ... first record extends into the GUID in the second record, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Real to datetime - how to...?
    ... would like to have it in hh:mm:ss format. ... The division with 24 is necessary, because a datetime value consists ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Format a datetime columns output?
    ... you could convert the date to a string? ... SQL Server you should use the format YYYYMMDD, ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Error SQL 7.0
    ... I suggest you download and install the latest update for SQL Server 2000 Books Online. ... suggestions for most of the corruption errors. ... the page header =. ...
    (microsoft.public.sqlserver.server)