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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Is there a way to write a SQL Query into a TXT file and execute it from PBI?

Dear PBI users, good afternoon.

 

Currently we are analyzing dividing the development team into front-end - UI / UX design (mostly focusing on the PBI charts , UI and overall UX) and Back-end (SQL Querying, Table optmization etc).

 

Esentialy the idea is to allow both teams to work on the report at the same time. The conclusion was, we would like the team to write the sql query into a TXT file and we would connect into the TXT and excute the query written on it.

 

Unfortunately I am not very known on this process, I know how to get the content of a txt but not to execute the written query against a database within PBI.

 

Would anyone have a clue how to do it?

 

Thank you!

2 ACCEPTED SOLUTIONS
ThxAlot
Super User
Super User

I managed to apply the same mode in our team last year, i.e. we use PQ to read sql files stored in a centralized sql depository; we are able to compile sql easily.

let
    // applicable to .txt / .sql files
    Source = "C:\Users\Home\Downloads\Qry.sql",
    SqlContent = Text.Combine(Table.ToColumns(Csv.Document(File.Contents(Source))){0}, "#(lf)")
in
    SqlContent

ThxAlot_0-1682698774338.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

Sql.Database("server", "database", [Query=SQLContent])


Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

5 REPLIES 5
ThxAlot
Super User
Super User

I managed to apply the same mode in our team last year, i.e. we use PQ to read sql files stored in a centralized sql depository; we are able to compile sql easily.

let
    // applicable to .txt / .sql files
    Source = "C:\Users\Home\Downloads\Qry.sql",
    SqlContent = Text.Combine(Table.ToColumns(Csv.Document(File.Contents(Source))){0}, "#(lf)")
in
    SqlContent

ThxAlot_0-1682698774338.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Anonymous
Not applicable

Exactly what we want to do , quick question @ThxAlot , and how do you execute it?

 

something like a blank query with 

 

= Sql.Database("server", "view", [Query=SQLContent])?

Sql.Database("server", "database", [Query=SQLContent])


Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Anonymous
Not applicable

Amazing! Just out of curiosity, how was the development after implementing this method? Overall better?

In terms of performance, this mode isn't better than hard-coded PQ queries; the biggest advantage is segregation; front-end and back-end devs may focus on their domain respectively.



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.