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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Sql commands not allowed in Direct query mode?

Is it only the SELECT sql command which is allowed in Direct query mode?

 

I get error message when I try to update my PowerBI Desktop project with a L language Direct query mode script that run a sql expression that start with the USE <db name> command. (There was no error message when saving the M script in the Advanced editor).

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

yes and no.  You can run whatever SQL injection you want, little Bobby Tables. HOWEVER !!! Chris Webb's BI Blog: Why Is Power BI Running My SQL Query Twice? (crossjoin.co.uk)  In short - don't get any ideas. It's not worth it.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

I got a very excellent explanation and solution from Chris Webb in another post.

Direct query syntax returns data in PowerQuery perfectly but shows error when update PowerBI project 

He noted that "Basically, if you can't use your SQL query as a subquery then you can't use it as a source in DirectQuery mode."

 

To my great relief all my trouble dissapeared when he explaned the workaround to apply table valued function as a source in DirectQuery mode TSQL Table-Valued Functions And Dynamic M Parameters In Power BI DirectQuery 

lbendlin
Super User
Super User

yes and no.  You can run whatever SQL injection you want, little Bobby Tables. HOWEVER !!! Chris Webb's BI Blog: Why Is Power BI Running My SQL Query Twice? (crossjoin.co.uk)  In short - don't get any ideas. It's not worth it.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors