Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
Problem with BULK INSERT
Problem with BULK INSERT
Rate Topic
Display Mode
Topic Options
Author
Message
FelixG
FelixG
Posted Thursday, August 30, 2012 5:02 PM
SSC-Addicted
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 9:06 PM
Points: 417,
Visits: 265
I'm trying to use the BULK INSERT statement to populate some table from a TXT file.
In the TXT file field values are separated by the ^ character and the end of line is (new line)
Here goes an example of the the query used to import the data:
BULK INSERT dbo._example
FROM 'c:\temp\example.txt'
WITH
(
DATAFILETYPE='char',
FIELDTERMINATOR ='^',
ROWTERMINATOR = ''
)
The _example table has only one column (ENAME) of varchar datatype.
When all the lines of the TXT table contain text without accents all goes right but when the file contains some accented caracter (é, á for example) then I get the error:
Msg 4863, Level 16, State 1, Line 1
Bulk load data conversion error (truncation) for row 3, column 1 (ENAME).
¿What am I missing there?
Post #1352529
Nesuke
Nesuke
Posted Thursday, September 06, 2012 3:27 AM
Forum Newbie
Group: General Forum Members
Last Login: Thursday, April 11, 2013 2:31 AM
Points: 8,
Visits: 26
Why have '^' as a delimiter for a start?
Anyway, the problem is probably the encoding of the txt file, make sure it's Unicode. Make sure your type is 'varchar' and not 'nvarchar'. Make sure the collation of the column is Latin1_General_CI_AS.
Post #1355148
RBarryYoung
RBarryYoung
Posted Thursday, September 06, 2012 10:20 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Saturday, May 04, 2013 11:13 AM
Points: 9,855,
Visits: 9,374
In particular, make sure that your source text file is not in UTF-8 format.
-- RBarryYoung
,
(302)375-0451
blog:
MovingSQL.com
, Twitter:
@RBarryYoung
Proactive
Performance Solutions, Inc.
"Performance is our middle name."
Post #1355463
FelixG
FelixG
Posted Wednesday, September 12, 2012 10:11 PM
SSC-Addicted
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 9:06 PM
Points: 417,
Visits: 265
Yes!!! I just converted the txt file to UNICODE ant it worked fine... Thanks a lot!!!!
Post #1358330
RBarryYoung
RBarryYoung
Posted Thursday, September 13, 2012 11:25 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Saturday, May 04, 2013 11:13 AM
Points: 9,855,
Visits: 9,374
Glad we could help.
-- RBarryYoung
,
(302)375-0451
blog:
MovingSQL.com
, Twitter:
@RBarryYoung
Proactive
Performance Solutions, Inc.
"Performance is our middle name."
Post #1358734
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.