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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
vinodhkannan
New Member

query

Hi - So I have developed power BI File connecting to MSSQL Database, amd I am using around 8 tables. The report is as expected. Is it possible for me to convert this to a SQL query?

3 REPLIES 3
Eric_Zhang
Microsoft Employee
Microsoft Employee


@vinodhkannan wrote:

Hi - So I have developed power BI File connecting to MSSQL Database, amd I am using around 8 tables. The report is as expected. Is it possible for me to convert this to a SQL query?


@vinodhkannan

What do you mean "convert to a SQL query"? As you use 8 tables, so you may have to create 8 individual queries to get data. Alternatively your can get data by SQL with Tables JOIN statement accordingly if you don't think all individual tables are necessary.

@Eric_Zhang I think what @vinodhkannan was trying to do is convert the M query to SQL. Even if he has 8 tables as the result of 8 separate queries, could those 8 queries be turned into SQL?

 

As in my case, I'm using T-SQL to query SQL Server 2012 DB using the native sql query functionality in PowerBI. However, if I build a query using M within PowerBI, I couldn't then use that code to query the database directly in SSMS or use that code to use in a stored proc, or build a view, etc.  

 

I am looking for a compiler that would take the M code and produce valid SQL, but I'm not sure if that currently exists?

@d_brew I did a little bit of research on this, as far as I had seen that kind of conversion (M query to SQL) was not possible.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors