0

I have a CSV file -- > named -- myWidechar1.csv and the data in it is as follows:

1~"ϴAnthony"~"Grosse"~"1980-02-23"~"65000.00"
2~"❤Alica"~"Fatnowna"~"1963-11-14"~"45000.00"
3~"☎Stella"~"Rossenhain"~"1992-03-02"~"120000.00"

Copy Command in PostgreSQL is as follows:

Copy dbo.myWidechar From 'D:\temp\myWidechar1.csv' DELIMITER '~' null as 'null'  encoding 'windows-1251' CSV; select 1;

But problem is I am getting the below error while importing data into PostgreSQL:

ERROR: invalid byte sequence for encoding "WIN1251": 0x00 CONTEXT: COPY mywidechar, line 3 SQL state: 22021

I need the data to remain same even in PostgreSQL as I am migrating data from SQL Server 2000 instance.

Can some one please help me in resolving this issue ?

10
  • 2
    From the error, it looks like the encoding is not proper. I don't see your characters listed on this page: en.wikipedia.org/wiki/Windows-1251 Commented Feb 22, 2019 at 18:35
  • @Jacob, can you please advise on what encoding I should use? I am new to PostgreSQL Commented Feb 22, 2019 at 18:38
  • I'm not a Posgres person either, but maybe this will help: stackoverflow.com/questions/30916853/… Commented Feb 22, 2019 at 18:39
  • 1
    If this is coming from windows-land then that may be UTF-16LE. I would agree that the heart and phone are not in the Win-1251 encoding. Telephone is 0x260E, for instance. Although if the normal characters (0-9a-zA-Z) aren't also two byte, then you may have luck just going UTF-8 and seeing what shakes out. Commented Feb 22, 2019 at 18:40
  • If it really is UTF-16, you'll have to convert the data to something else first. Commented Feb 22, 2019 at 18:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.