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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Requesting TOP 5000 Rows from SQL Database

Hi! 

 

i have a problem i cant solve without your help.

I am connecting to a SQL Server where i need data from 2 large databases.

Both of them have a column with a time stamp (only date). Now i just want to querry the data from the last 2 Days - that means like 5000 rows filtered per Date.

 

I know i could import all data and then using power querry to sort and select top 5000 but then all the data gets extracted during the import. Is there an option to directly do it as SQL command? 

 

Like: Select Top 5000 * from database XY? Would it then be neccessary to sort it in the SQL database?

Really appreciate your help!

 

BR

Fabian

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could connect Sql server by connecting using advanced options. 

vyalanwumsft_0-1638511992605.png

Then if you need a 5000TOP import for both databases, you can split it into two write SQL statements in one .pbix .

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Is your problem solved? If so, Would you mind accept the helpful replies as solutions? Then we could close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could connect Sql server by connecting using advanced options. 

vyalanwumsft_0-1638511992605.png

Then if you need a 5000TOP import for both databases, you can split it into two write SQL statements in one .pbix .

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

HotChilli
Super User
Super User

I've not tried a cross-database query.  Is it the same server?

 

I suggest you experiment with your sql in SSMS and get it to work (I think it should be possible) then put it in Power Query and fire up sql profiler to see if the query passes through correctly

HotChilli
Super User
Super User

When you start a new query-> SQL Server, the dialog has a section    ->SQL statement (optional)

Anonymous
Not applicable

Thank you. And can i also use a SQL command there to sort the SQL database based on the date column? And can i just write the statements one to the next because i retreive data from two databases?

 or do i need to create a second querry? 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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