Solved

why there is problem with bulk insert

Posted on 2011-02-27
5
771 Views
Last Modified: 2012-06-27
First, I create table:
CREATE TABLE [dbo].[ResultsOrdered](
      [DrawDate] [varchar](10) NOT NULL,
      [Sh1] [tinyint] NULL,
      [Sh2] [tinyint] NULL,
      [Sh3] [tinyint] NULL,
      [Sh4] [tinyint] NULL,
      [Sh5] [tinyint] NULL,
      [Sh6] [tinyint] NULL
)

then I am trying to populate it with data from text file where each row is in format:
dd.MM.yyyy 01 02 03 04 05 06(delimeters are horizontal tabs)

with  bulk insert:
bulk insert ResultsOrdered
from 'c:\ResultsOrdered.txt'
with
(
 
  rowterminator='\n',
  fieldterminator='\t'
 
)

and get the error:
Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 (DrawDate).

What do  I do wrong?
0
Comment
Question by:AlexKostrub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 34991115
hi

it seems your tring to load date into varchar.
try changing the column type in the table to datetime.
or remove the " . " (period) from the date in the flat file.
0
 

Author Comment

by:AlexKostrub
ID: 34991251
Using Date type for the first column produces similar error(even with set dateformat dmy). Why I can not load date-semilar data into varchar when it is also a sequence of symbols?
0
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 34991288
i think the issue with datetime format 16/11/1909 (dd/mm/yyyy) while sql server may be expecting in mm/dd/yyyy format
0
 
LVL 78

Expert Comment

by:arnold
ID: 34992452
Could you post a snippet of the data?
0
 
LVL 13

Accepted Solution

by:
ispaleny earned 250 total points
ID: 34993503
Try

bulk insert ResultsOrdered
from 'c:\ResultsOrdered.txt'
with
(
  CODEPAGE = 'RAW',
  rowterminator='\n',
  fieldterminator='\t'
 
);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question