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

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

Reply
Markzolotoy
Impactful Individual
Impactful Individual

Create a query to select data from a table

How do I write a query to select data from a SQL table? I mean an SQL statement to get specific data from te table.

 

Thanks

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

When you connect to SQL Server, expand the "Advanced options" as show in the screen shot below and then just paste in your SQL code.

SQL Server Database.png



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

That is when I import data. But about pulling data at real time? 

Anonymous
Not applicable

Hi Markzolotoy,

Do you connect to the table from on-premises SQL Server database in Power BI Desktop and want to pull data at real time? If that is the case, there is no such feature in Power BI Desktop. However we can manually change query to select different data using Advanced Editor of Query Editor, for more details about Advanced Editor, please review the this article: https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-query-overview/ .

Moreover, we can utilize the Schedule Refresh feature to refresh dataset created from Power BI Desktop files imported from a local drive where Get Data/Query Editor is used to connect to and load data from on-premises SQL Server database. For more details, please review the following articles.

https://powerbi.microsoft.com/en-us/documentation/powerbi-refresh-desktop-file-local-drive/
https://powerbi.microsoft.com/en-us/documentation/powerbi-refresh-data/#understanding-data-refresh

Thanks,
Lydia Zhang

so if i wanted to select data from a view in a DB2 database, i cannot create a datasource of that nature is that correct?  I have successfully created the data source for said DB2 connection and am able to pull all the data from the view but i would like to limit it further with SQL.  Thanks

Should be essentially the same process. See the Advanced options here for DirectQuery from Azure SQL Database:

 

https://powerbi.microsoft.com/en-us/documentation/powerbi-azure-sql-database-with-direct-connect/

 

Advanced options provides a Custom filters section, and supplies an example of a SELECT statement.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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