Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

BulkImport Problem Expand / Collapse
Author
Message
Posted Tuesday, August 21, 2012 4:14 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, August 22, 2012 2:07 AM
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') ;



  Post Attachments 
DataImport.rar (10 views, 950 bytes)
Post #1347675
Posted Tuesday, August 21, 2012 5:18 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 2:56 PM
Points: 4,119, Visits: 5,485
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”
Post #1347715
Posted Tuesday, August 21, 2012 5:21 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 2:56 PM
Points: 4,119, Visits: 5,485
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”
Post #1347716
Posted Tuesday, August 21, 2012 5:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, August 22, 2012 2:07 AM
Points: 5, Visits: 16
Yes,
I tried that but did not work.
Post #1347719
Posted Tuesday, August 21, 2012 9:22 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, November 14, 2014 10:58 AM
Points: 2,706, Visits: 3,426
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
SQL Know-It-All

How to post data/code on a forum to get the best help - Jeff Moden
Post #1347870
Posted Tuesday, August 21, 2012 10:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, August 22, 2012 2:07 AM
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)".
Post #1347912
Posted Tuesday, August 21, 2012 10:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, August 22, 2012 2:07 AM
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
Post #1347925
Posted Wednesday, August 22, 2012 2:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, August 22, 2012 2:07 AM
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




Post #1348240
Posted Thursday, August 23, 2012 1:25 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 12:35 AM
Points: 80, Visits: 215
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.

Post #1348894
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse