Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have a problem with this query:-

SQL
BEGIN
truncate table dbo.BaaN_BOM
BULK
INSERT dbo.BaaN_BOM
FROM 'C:\OutputFiles\BOM.txt'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
end


Four columns in this table.
DataBase dbo.BaaN_BOM Table:- CustID (varchar(max)), CustomerName(varchar(max)) Address(varchar(max)) ErrorIndicator (int)

BOM.txt:- CustID|CustomerName|Address|ErrorIndicator
C_001|Raj|Noida|1
C_002|Jason|Australia|0
C_003|Nathan|England|1
C_004|Ankit|India|1

So,
I want to fill data from BOM.txt to My dbo.BaaN_BOM table but i have problem with ErrorIndicator
because It's a Integer Type and filled the data from this query like:-

CustID CustomerName Address ErrorIndicator
CustID CustomerName Address ErrorIndicator
C_001 Raj Noida


I want to only data fill not column insert, So,How it can be possible.

Please help me.

Thanks in Advance
Ankit
Software Engineer
Posted

1 solution

FIRSTROW =first_row
Specifies the number of the first row to load. The default is the first row in the specified data file. FIRSTROW is 1-based.

Note
The FIRSTROW attribute is not intended to skip column headers. Skipping headers is not supported by the BULK INSERT statement. When skipping rows, the SQL Server Database Engine looks only at the field terminators, and does not validate the data in the fields of skipped rows.

http://msdn.microsoft.com/en-us/library/ms188365.aspx[^]

Update:
I guess you'd better use the bcp utility for your data import.
http://msdn.microsoft.com/en-us/library/ms175937.aspx[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900