Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

why there is problem with bulk insert

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in 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.

618 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