all groups > sql server programming > june 2005 >
You're in the

sql server programming

group:

Bcp error with format file



Bcp error with format file Chuck Lathrope
6/22/2005 10:15:39 PM
sql server programming: I am trying to import 2 columns from a 3 column file, but I get:
C:\temp\>bcp soar.dbo.remarks_temp in remarks.txt -f bcp.fmt
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]I/O error while reading BCP
format file

Here is the template file:
8.0
3
1 SQLCHAR 0 20 "|" 1 SLN
SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 0 "|" 0
dontwant SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 7000 "\r\n" 2
Remarks SQL_Latin1_General_CP1_CI_AS

Txt import file sample:

12344556|2|Whole lot of text here
12344557|1|Whole lot of text here 2

Destination table:

CREATE TABLE [dbo].[Remarks_Temp] (
[SLN] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Remarks] [varchar] (7000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

The second column in the text file is what I want to ignore.

I have looked at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_impt_bcp_57qd.asp
many many times, but there example is too convenient, I don't have ability
to modify the source text file to move the uneeded columns at the end of the
row.

Thanks,
Chuck


RE: Bcp error with format file John Bell
6/22/2005 11:48:02 PM
Hi

THis is working for me!!!

8.0
3
1 SQLCHAR 0 20 "|" 1 SLN
SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 1 "|" 0 Dummy
SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 7000 "\r\n" 2
Remarks SQL_Latin1_General_CP1_CI_AS

The only difference seems that the second column needs a length.

John

[quoted text, click to view]
Re: Bcp error with format file Ami Levin
6/23/2005 12:00:00 AM
Hi Chuck,

I remember encountering this error message when there was a missing <CR><LF>
at the end of the format file.
Just open the format file with any text editor and add <enter> at the end of
the last line.

HTH


[quoted text, click to view]

Re: Bcp error with format file Chuck Lathrope
6/23/2005 10:12:07 AM
This did the trick. Now how am I going to automate this? Any ideas?

Thanks,
Chuck

[quoted text, click to view]

Re: Bcp error with format file Ami Levin
6/24/2005 12:00:00 AM
HI chuck,

You can create a SQL Server Agent job with a Command Shell step (or use a
T-SQL step with BULK Insert) to run the import on schedule / on demand.

HTH

Ami


[quoted text, click to view]

AddThis Social Bookmark Button