Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7068515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:20:00+00:00 2026-05-28T05:20:00+00:00

Good afternoon to all, I have this scenario: I am using SQL Server ‘BulkInsert’

  • 0

Good afternoon to all, I have this scenario:
I am using SQL Server ‘BulkInsert’ command to insert data in a table from a positional (.txt) file.
I use, to define structure of the file, a .xml file that defines position (and lenght) of the fields and their names.

These are 2 sample rows of the .txt positional file:

AAA111111Surname 1           Name 1               
BBB222222Surname 23          Name 99   

My .xml format file is defined as below:

<?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="CharFixed"   LENGTH="3"  />
  <FIELD ID="2" xsi:type="CharFixed"   LENGTH="6"  />
  <FIELD ID="3" xsi:type="CharFixed"   LENGTH="20"  />
  <FIELD ID="4" xsi:type="CharFixed"   LENGTH="20"  />
  <FIELD ID="5" xsi:type="CharTerm" TERMINATOR="\r\n"  />
 </RECORD>

 <ROW>
  <COLUMN SOURCE="1" NAME="AlfaCode" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="2" NAME="NumericCode" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="3" NAME="Surname" xsi:type="SQLNVARCHAR"/>
  <COLUMN SOURCE="4" NAME="Name" xsi:type="SQLNVARCHAR"/>
 </ROW>
</BCPFORMAT>

My SQL Server code is:

DELETE from MY_TABLE

BULK INSERT MY_TABLE FROM 'C:\Directory\InputFile.txt'
   WITH (
      FORMATFILE = 'C:\Directory\FormatFile.xml' 
                )

But when I run in SQL Server the sp, I have the following error:

Msg 4866, Level 16, State 1, Line 3
The bulk load failed. The column is too long in the data file for row 1, column 58. Verify that the field terminator and row terminator are specified correctly.
Msg 7399, Level 16, State 1, Line 3
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 3
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

This has always run perfectly until 2 months ago, then some wrong data were introduced into the file and procedure failed. Now data into the InputFile.txt are correct again, but procedure doesen’t work
I checked more than 1 time InputFile.txt, FormatFile.xml and, to be sure, also MY_TABLE, but all seems perfect.

I am desperate because all seems ok, I compared also old .xml files substiuted adding only some fields.

Please answer ASAP and sorry if my english is very bad.
Don’t esitate to tell me other informations.

Thanks to all

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:20:01+00:00Added an answer on May 28, 2026 at 5:20 am

    I think it’s most likely your input file must still be wrong. (even though you think you fixed it).

    In your example, you have 50 characters on line 1 before the line break.
    Your XML says you should only have 49 chars! (3+6+20+20)
    Your second line in the example only has 39 characters before the linebreak.

    It’s probably also worth opening your txt file in a text editor that will show you the line breaks. For instance, in notepad++, go to View -> Show Symbol -> Show All Characters. Then you can see the CR and LF characters, to verify they are there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Afternoon All, I have two tables in my SQL Server 2005 DB, Main
Good afternoon all, I have a class which looks like this: public class Grapheme
Good afternoon all, I'm using a java.lang.StringBuilder to store some characters. I have no
Good afternoon all Here is my scenario: I have user controls within a master
Good afternoon all. I have a page that displays data in a gridview based
Good Afternoon All, I have a wizard control that contains 20 textboxes for part
Good afternoon all, I dont know why this is proving so difficult but I
Good Afternoon All, I have written an SSIS 2005 package that contains a conditional
Afternoon All, I have a stored procedure in an SQL 2005 database named GasNominationsRawData_Insert.
Good afternoon one and all, I've recently deployed a website on a remote server,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.