Character with encoding UTF8 has no equivalent in WIN1252

后端 未结 10 1024
挽巷
挽巷 2020-12-29 02:41

I am getting the following exception:

Caused by: org.postgresql.util.PSQLException: ERROR: character 0xefbfbd of encoding \"UTF8\" has no equivalent in \"WIN         


        
10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 03:05

    Here's what worked for me : 1 enable ad-hoc queries in sp_configure. 2 add ODBC DSN for your linked PostgreSQL server. 3 make sure you have both ANSI and Unicode (x64) drivers (try with both). 4 run query like this below - change UID, server ip, db name and password. 5 just keep the query in last line in postgreSQL format.

    EXEC sp_configure 'show advanced options', 1
    RECONFIGURE
    GO
    EXEC sp_configure 'ad hoc distributed queries', 1
    RECONFIGURE
    GO
    
    SELECT * FROM OPENROWSET('MSDASQL', 
    'Driver=PostgreSQL Unicode(x64); 
    uid=loginid;
    Server=1.2.3.41;
    port=5432;
    database=dbname;
    pwd=password',
    
    'select * FROM table_name limit 10;')
    

提交回复
热议问题