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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
comish4lif
Helper II
Helper II

"Unable to Connect" to IBM DB2 Database via SQLStatement

I am trying to pull data from a DB2 data warehouse. I have set up the connection string and database name. I am using the following very simple query:

 

select *

from AEHRDW.FEMPRFDEM

where FEMPRFDEM_effto_dt = '9999-12-31'

AND FEMPRFDEM_CURR_IND = 'Y'

WITH ur;

 

And this is the text from the error that I am receiving:

SQLError42601.jpg

The way that I read the error, it is breaking up my code in the middle of my where clause.

 

Does anyone know the way around this?

 

1 ACCEPTED SOLUTION

Thanks for all of the comments and suggestions. The SQL that I begin with was written and tested in IBM Data Studio.

 

But here's what solved it for me - I removed the semi-colon at the end of the SQL, and it works just fine now.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @comish4lif,

 

Based on error message, your issue seems related to 'WITH' function.

Please check below link to know more about 'WITH' function or try to remove 'with ur' part and try again.

WITH - Common Table Expressions

 

Regards,

Xiaoxin Sheng

Thanks for the help, I've removed the "With UR" line of code but the query still will not execute. It presents the same error, but breaks the text at a different position in the Where clause.

 

 

Details: "Microsoft Db2 Client: An unexpected token "" was found following "". Expected tokens may include: "FDEM_CURR_IND = 'Y'
". SQLSTATE=42601 SQLCODE=-104"

 

If I just connect to my DB2 source, I can see the list of tables and view the previews. But my tables are large, and I can not load any of them, which is why I am trying to load some smaller extracts from the larger tables. Is there a more detailed DB2 tutorial - and not just the generic "Connect to a database" help?

Anonymous
Not applicable

Hi @comish4lif,

 

Based on research, this issue caused by syntax exception, you can try to copy current query to DB2 client and run it.

DB2 client will highlight the syntax that caused the error, you can modify on db2 client and copy the right query to power bi.

 

Regards,
Xiaoxin Sheng

Thanks for all of the comments and suggestions. The SQL that I begin with was written and tested in IBM Data Studio.

 

But here's what solved it for me - I removed the semi-colon at the end of the SQL, and it works just fine now.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors