Forum Discussion
Is there a way to write a SQL Query into a TXT file and execute it from PBI?
- 3 years ago
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 - 3 years ago
Sql.Database("server", "database", [Query=SQLContent])
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
SqlContentExactly 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])?
- ThxAlot3 years agoSuper User
Sql.Database("server", "database", [Query=SQLContent])- Anonymous3 years agoNot applicable
Amazing! Just out of curiosity, how was the development after implementing this method? Overall better?
- ThxAlot3 years agoSuper User
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.