?
Solved

why there is problem with bulk insert

Posted on 2011-02-27
5
Medium Priority
?
773 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 79

Expert Comment

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

Accepted Solution

by:
ispaleny earned 1000 total points
ID: 34993503
Try

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

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

770 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