|
|
|
Forum 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') ;
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 8:31 AM
Points: 3,129,
Visits: 4,312
|
|
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”
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 8:31 AM
Points: 3,129,
Visits: 4,312
|
|
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”
|
|
|
|
|
Forum 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.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 8:11 AM
Points: 2,613,
Visits: 3,128
|
|
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
|
|
|
|
|
Forum 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)".
|
|
|
|
|
Forum 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
|
|
|
|
|
Forum 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
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 4:33 AM
Points: 48,
Visits: 159
|
|
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.
|
|
|
|