Saturday, February 25, 2012

Bulk Insert - Fixed Length File

I'm trying to do an insert using Bulk Insert with a fixed length file.
I'm using a format file.
I'm getting the following error message:
Cannot perform bulk insert. Invalid collation name for source column 16
in format file '\\wbhq.com\dfsdv\iDataInt\GOPFiles\GOPFormatFile. txt'.

Any suggestions are appreciated.

Thanks!
Jennifer

Format File Contents:
8.0
16
1SQLCHAR02""0Space""
2SQLCHAR04""1YearID""
3SQLCHAR02""0Space""
4SQLCHAR02""2PeriodID""
5SQLCHAR02""3CompanyID""
6SQLCHAR01""0Dash""
7SQLCHAR04""0Space""
8SQLCHAR01""0Dash""
9SQLCHAR04""4UnitID""
10SQLCHAR01""0Dash""
11SQLCHAR04""5AccountCode""
12SQLCHAR05""0Space""
13SQLCHAR01""6AccountType""
14SQLCHAR029""0Space""
15SQLCHAR016""7GLAmount""
16SQLCHAR0105"\r\n"0Space""

Bulk Insert Statement:
BULK INSERT FlatFile_GOP
FROM '\\wbhq.com\dfsdv\iDataInt\GOPFiles\GLPAM.GOP'
WITH
(
FORMATFILE =
'\\wbhq.com\dfsdv\iDataInt\GOPFiles\GOPFormatFile. txt'
)

Table Definition:
CREATE TABLE [dbo].[FlatFile_GOP] (
[YearID] [smallint] NOT NULL ,
[PeriodID] [smallint] NOT NULL ,
[CompanyID] [smallint] NOT NULL ,
[UnitID] [smallint] NOT NULL ,
[AccountCode] [int] NOT NULL ,
[AccountType] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
,
[GLBalance] [money] NOT NULL
) ON [PRIMARY]
GO

File Contents:
2007 210- -0002-3000 G
196395.10

2007 210- -0002-3700 B
1484.00

2007 210- -0002-3700 G
1571.13

2007 210- -0002-3800 B
157457.00

2007 210- -0002-3800 G
161577.73Jennifer (J.Evans.1970@.gmail.com) writes:

Quote:

Originally Posted by

I'm trying to do an insert using Bulk Insert with a fixed length file.
I'm using a format file.
I'm getting the following error message:
Cannot perform bulk insert. Invalid collation name for source column 16
in format file '\\wbhq.com\dfsdv\iDataInt\GOPFiles\GOPFormatFile. txt'.


I was not able to repeat this. Then again, I was not able to import the
file successfully either, but the error message I got was:

Server: Msg 4864, Level 16, State 1, Line 1
Bulk insert data conversion error (type mismatch) for row 1, column 15
(GLBalance).
Server: Msg 4864, Level 16, State 1, Line 1
Bulk insert data conversion error (type mismatch) for row 2, column 15
(GLBalance).

which makes me think that the format file was interpreted OK. (And the
reason for the error is simply that your file was mashed in news transport,
and I did not really make any effort to resurrect it.)

Since column 16 is a column you are not even importing the message seems
funny to me. My prime suspicions that the contents of

Quote:

Originally Posted by

'\\wbhq.com\dfsdv\iDataInt\GOPFiles\GOPFormatFile. txt'


is not what you think it is.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

No comments:

Post a Comment