SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


BulkImport Problem


BulkImport Problem

Author
Message
dev7.patel
dev7.patel
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 16
I have Unicode Data file which is Fixed Length
Following Table Structure with Create Statement.

sample Data file and format file i used attached in DataImport.rar
I tried to change format file with other possibilities But non of it inserts data perfactly.
So Please can any one tell me that what i am doing wrong?
is it wrong with format file or where?



CREATE TABLE [dbo].[Tab_Import]
(
[COLUMN1] [nvarchar] (4) COLLATE Danish_Norwegian_CI_AS NULL,
[COLUMN2] [nvarchar] (3) COLLATE Danish_Norwegian_CI_AS NULL,
[COLUMN3] [nvarchar] (50) COLLATE Danish_Norwegian_CI_AS NULL
) ON [PRIMARY]
GO

BULK INSERT dbo.Tab_Import
FROM 'D:\DataImport\Tab_Import.Dat'
WITH (FORMATFILE = 'D:\DataImport\Tab_Import.Fmt') ;


Attachments
DataImport.rar (13 views, 950 bytes)
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8833 Visits: 7281
Have you tried including the option:
DATAFILETYPE = 'widenative' 



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8833 Visits: 7281
Please see Using Unicode Character Format to Import or Export Data for further information, especially the section Command Options for Unicode Character Format

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
dev7.patel
dev7.patel
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 16
Yes,
I tried that but did not work.
Jared Karney
Jared Karney
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4966 Visits: 3694
1. Your format file specifies #bytes, not characters. Since it is nvarchar, you need to double them in your format file.

2. Your row terminator is not "\r", it is just ""

Like this:

10.0
3
1 SQLNCHAR 0 8 "" 1 COLUMN1 Danish_Norwegian_CI_AS
2 SQLNCHAR 0 6 "" 2 COLUMN2 Danish_Norwegian_CI_AS
3 SQLNCHAR 0 100 "\" 3 COLUMN3 Danish_Norwegian_CI_AS

EDIT: of course, it will not show a backslash n, so make sure you add the n to the backslash.

Thanks,
Jared
PFE - Microsoft
SQL Know-It-All
How to post data/code on a forum to get the best help - Jeff Moden
dev7.patel
dev7.patel
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 16
SQLKnowItAll

i have done now same as you said but i am getting error.
i used \ n as row terminator as specified for last row.






Msg 4863, Level 16, State 1, Line 1
Bulk load data conversion error (truncation) for row 1, column 3 (COLUMN3).
Msg 4863, Level 16, State 1, Line 1
Bulk load data conversion error (truncation) for row 2, column 3 (COLUMN3).
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

dev7.patel
dev7.patel
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 16
I got Correct File how it is just i have to add \r\0\0

10.0
3
1 SQLNCHAR 0 8 "" 1 Column1 Danish_Norwegian_CI_AS
2 SQLNCHAR 0 6 "" 2 Column2 Danish_Norwegian_CI_AS
3 SQLNCHAR 0 100 "\r\0\0" 3 Column3 Danish_Norwegian_CI_AS






EDIT: in 3rd Line it is \r\0\ n\0


SQLKnowItAll and
Stewart "Arturius" Campbell Thanks for help
dev7.patel
dev7.patel
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 16
I got Correct File how it is just i have to add \r\0\0

10.0
3
1 SQLNCHAR 0 8 "" 1 Column1 Danish_Norwegian_CI_AS
2 SQLNCHAR 0 6 "" 2 Column2 Danish_Norwegian_CI_AS
3 SQLNCHAR 0 100 "\r\0\0" 3 Column3 Danish_Norwegian_CI_AS





webtomte
webtomte
SSC-Enthusiastic
SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)

Group: General Forum Members
Points: 139 Visits: 226
Hi,

I have worked some with translation from Unix to PC encoding.
The main problem to BULK INSERT is that it has problems reading Unicode text documents as it does not have "CR" (Carrige Return) at the end of a row, only "LF".
By adding (there are some apps doing this, mainly on the UNIX side) a "CR" to the end of every line will solve the problem.

Also open the txt file in TextPad or NotePad++ and saving it in PC-format will do the trick.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search