Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

PostgreSQL: 22021: invalid byte sequence for encoding "UTF8" ODBC

Hello @v-danhe-msft 

 

Please help me.. I have the same issue when I get data from ODB or directly from PostgreSql.

Some tables I can import the table to powerquery and see it, but i cant aply it to powerbi desktop.

Other tables i cant even see it at powerquery.

 

Failed to save modifications to the server. Error returned: 'Erro do OLE DB ou ODBC: [datasource.error] PostgreeSQL: 22021: invalid byte sequence for encoding "UTF8": 0xc7 0x4f. ' .

 

From ODBC:

DataSource.Error: ODBC: ERROR [22021] ERROR: invalid byte sequence for encoding "UTF8": 0xe9 0x20 0x41;
Error while executing the query
Detalhes:
DataSourceKind=Odbc
DataSourcePath=dsn=PostgreSQL35W32b
OdbcErrors=[Table]

 

FROM POSTGRE:

DataSource.Error: PostgreSQL: 22021: invalid byte sequence for encoding "UTF8": 0xc7 0xc3
Detalhes:
DataSourceKind=PostgreSQL
DataSourcePath=000.000.0.0;TESTE
Message=22021: invalid byte sequence for encoding "UTF8": 0xc7 0xc3
ErrorCode=-2147467259

 

MY DATABASE:

CREATE DATABASE "TESTE"
WITH OWNER = postgres
ENCODING = 'SQL_ASCII'
TABLESPACE = pg_default
LC_COLLATE = 'Portuguese_Brazil.1252'
LC_CTYPE = 'Portuguese_Brazil.1252'
CONNECTION LIMIT = -1;

ALTER DATABASE "TESTE"
SET DateStyle = 'iso, mdy';
ALTER DATABASE "TESTE"
SET bytea_output = 'escape';
ALTER DATABASE "TESTE"
SET standard_conforming_strings = 'off';

 

MY ODBC Config:

datasourse int-8 as default

extra op 0x0

byte as LO

1 ACCEPTED SOLUTION
Anonymous
Not applicable

SET UP ODBC AS "POSTGRESQL ANSI"

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

The ERP developer of this database told me that I need to make PowerBi to read the database as "SQL_ASCII" - not as utf8.

Is it right?

How can I solve it?

Anonymous
Not applicable

SET UP ODBC AS "POSTGRESQL ANSI"

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.