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 7605959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:17:42+00:00 2026-05-31T00:17:42+00:00

Hello everyone I have a difficult problem with using BULK INSERT command when I

  • 0

Hello everyone I have a difficult problem with using BULK INSERT command when I try to import data from text file.

I found many articles and examples in Internet about importing with BULK INSERT or BCP program, but they not help to me.

The problem:
I make export from Oracle into text file with column delimiter {#} and row delimiter <#> and import it into SQL Server.

The table is (SQL Server):

CREATE TABLE my_DATA
(
ID_PK     NUMERIC(30)  NOT NULL ,
BEGIN_TIME    DATETIME  NULL ,
END_TIME      DATETIME  NULL
);

for Oracle:

CREATE TABLE my_DATA
(
ID_PK     NUMBER(30)  NOT NULL ,
BEGIN_TIME    TIMESTAMP  NULL ,
END_TIME      TIMESTAMP  NULL
);

The file with delimiter is:

ID_PK{#}BEGIN_TIME{#}END_TIME<#>296167{#}01/01/2012 01:30:00.000{#}01/01/2012 02:00:00.000<#>296178{#}01/01/2012 02:00:00.000{#}01/01/2012 02:30:00.000<#>

The format file is:

9.0                         
3                           
1   SQLNUMERIC  0   19  {#} 1   ID_PK   ""
2   SQLDATETIME 0   8   {#} 2   BEGIN_TIME  ""
3   SQLDATETIME 0   8   <#> 3   END_TIME    ""

So when I used command:

BULK INSERT my_DATA 
FROM 'D:\my_DATA.txt' 
WITH 
(CODEPAGE = '1251',
 FIELDTERMINATOR = '{#}', 
 FIRSTROW = 2, 
 ROWTERMINATOR = '<#>' );

It works, but when I try to use format file it does not work:

BULK INSERT my_DATA 
FROM 'D:\my_DATA.txt' 
WITH (CODEPAGE = '1251',
      FORMATFILE ='D:\format_file.txt');

The error is:

Bulk load data conversion error (type mismatch or invalid character
for the specified codepage) for row 2, column 2 (begin_time).

I searched about this problem, try to change datetime to smalldate, try to change length to 23 or 24. It does not work. So I try to import another table without date, I use numeric column and char columns, but I faced with the same problem with numeric column:

Bulk load data conversion error (type mismatch or invalid character
for the specified codepage) for row 2, column 1 (id_pk).

table:

CREATE TABLE unit_table
(
id_pk  NUMERIC(30)  NOT NULL ,
name             NVARCHAR(200)  NULL ,
name_full        NVARCHAR(200)  NULL ,
CONSTRAINT  PK_unit_table_2C1 PRIMARY KEY (bule_biz_unit_level_id_pk)
);

format file:

9.0
3
1       SQLNUMERIC    0       1      "{#}"      1     id_pk                              ""
2       SQLNCHAR      0       11     "{#}"      2     name                                              ""
3       SQLNCHAR      0       11     "{#}"      3     name_full                                         ""

The data file contains only 3 rows (the bulk insert command is the same):

ID_PK{#}NAME{#}NAME_FULL<#>1{#}factory{#}factory<#>2{#}station{#}station<#>

It is interesting if file contains only 2 rows:

ID_PK{#}NAME{#}NAME_FULL<#>1{#}factory{#}factory<#>

The result of bulk insert is:

(0 row(s) affected)

I also try to do example http://msdn.microsoft.com/en-us/library/ms178129.aspx but face with error:

Cannot bulk load because the file “D:\myTest.txt” could not be read.
Operating system error code (null).

And the last, I tried to use this with bcp program and face with errors too.

Can anyone help me with my problem or give me at least one working example with bulk insert and format file.

P.S. I use MS SQL Server 2005 updated to last version. OS is Windows 7 x64.

  • 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-31T00:17:43+00:00Added an answer on May 31, 2026 at 12:17 am

    Thanks to all. But the problem was that MS SQL Server requires SQLCHAR type, when you importing from text file and it does not matter what column type in the database. In my problem the solution is replacing any column types, like SQLNUMERIC, SQLDATETIME to SQLCHAR in format file.

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

Sidebar

Related Questions

hello everyone I have some problem with understanding this piece of the code: import
Hello everyone I have a problem I'll try to describe shortly In our application
Hello everyone i have a problem in my application. The check in my check
Hello everyone i currently have this: import feedparser d = feedparser.parse('http://store.steampowered.com/feeds/news.xml') for i in
Hello everyone i want search data from invoices and client by today date I'm
hello everyone im trying to create this tweak that copies a file from one
hello everyone i have a problem with my 3-tiers application i don't know how
Hello everyone I have a problem. I'm trying to upload my application in the
Hello everyone I have some problem to grab movie title with regular expression. how
So hello everyone I have a big problem right now with a button that

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.