Solved

why there is problem with bulk insert

Posted on 2011-02-27
5
761 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
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 76

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now