I now prefer to use XML format files like this with BULK INSERT or OPENROWSET:
<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR="|" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="37"/>
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="41"/>
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR="|" MAX_LENGTH="17"/>
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="10" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="i" xsi:type="SQLCHAR"/>
<COLUMN SOURCE="2" NAME="j" xsi:type="SQLUNIQUEID"/>
<COLUMN SOURCE="3" NAME="k" xsi:type="SQLNUMERIC" PRECISION="18" SCALE="0"/>
<COLUMN SOURCE="4" NAME="l" xsi:type="SQLBINARY"/>
<COLUMN SOURCE="5" NAME="m" xsi:type="SQLVARYCHAR"/>
</ROW>
</BCPFORMAT>
Then you can use the server-side BULK INSERT command as follows:
BULK INSERT foo FROM '\\mydomain.com\bar\bletch' WITH (FORMATFILE='foo.xml', ERRORFILE='foo.errors', FIRSTROW = 1, BATCHSIZE=10000)
alternatively, if you want to modify the data 'in-flight', you can use the
INSERT foo(i, j,k)
SELECT foo_delimited.i, foo_delimited.j, foo_delimited.k * 2
OPENROWSET(BULK 'foo',
FORMATFILE= 'foo.xml')
AS foo_delimited