BULK INSERT Creates 2 rows from 1 row datafile

D

Demelash Gobeze

Greetings,

I have an .adp from which I want to BULK INSERT, bcp or INSERT INTO
from a data file. Interestingly when calling the stored procedure that
does the bulk insert from access vba code via cmd object it creates 2
rows in the target table while the datafile has only 1 data row. Why
could that be, could I trace this problem. Interestingly when I do
this in SQL Management Studio it creates only one row :O(

Here is the content of the DataFile.txt, tab delimited

Material Width Length Qty Under OrderNo
818164 12.65 26.5 25 23 PRL14

here is the content of the format.txt
8.0
6
1 SQLCHAR 0 50 "\t" 1 Material SQL_Latin1_General_CP437_BIN
2 SQLCHAR 0 50 "\t" 2 Width SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 50 "\t" 3 Length SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 50 "\t" 4 Qty SQL_Latin1_General_CP1_CI_AS
5 SQLCHAR 0 50 "\t" 5 Under SQL_Latin1_General_CP1_CI_AS
6 SQLCHAR 0 50 "\r\n" 6 OrderNo SQL_Latin1_General_CP1_CI_AS

Staging table is identical to datafile as far structure same fields
as you notice I only have "one row" on the data file the first row is
just header information which I bypass in my sproc by saying FIRSTROW
= 2 as on of the parameters in the syntax.

INSERT INTO dbo.StagingTable
SELECT DISTINCT Material,
Width,
Length,
Qty,
Under,
OrderNo
--SELECT *
FROM OPENROWSET(BULK '\\remoteserver\shareddrive
\TitanUnderReport.txt',
FORMATFILE = '\\remoteserver\shareddrive\format.txt',
FIRSTROW = 2)
AS Q
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top