PostgreSQL: Export data from SQL Server 2008 R2 to PostgreSQL 9.5

后端 未结 1 925
时光说笑
时光说笑 2021-01-26 09:48

I have a table to export data from SQL Server to PostgreSQL.

Steps I followed:

Step 1: Export data from SQL Server:

Source: SQL Server Table
Dest         


        
相关标签:
1条回答
  • 2021-01-26 10:05

    You tell Postgres the source would be encoded as LATIN1:

    \copy ... ENCODING 'LATIN1'
    

    But that's either not the case or the file is damaged. Else we would not see the error message. What is the true encoding of '$FilePath\file.txt'?

    The current client_encoding is not relevant for this since, quoting the manual on COPY:

    ENCODING

    Specifies that the file is encoded in the encoding_name. If this option is omitted, the current client encoding is used.

    (\copy is jut a wrapper for SQL COPY in psql.)

    And your server_encoding is largely irrelevant, too - as long as Postgres can use a built-in conversion and the target encoding contains all characters of the source encoding - which is the case for LATIN1 -> UTF8: iso_8859_1_to_utf8.

    So the remaining source of error is your file, which is almost certainly not valid LATIN1.

    0 讨论(0)
提交回复
热议问题