'Refresh of Excel Power Query with NativeQuery against SQL Server - executing twice
I'd like to use Power Query in Excel to insert data into SQL Server.
Using the technique in Power BI write back to sql source, I wrote the Power Query below:
let
Source = Sql.Database("server_host/instance_name", "database_name"),
TargTable = "my_table",
Sql1 = "INSERT INTO [" & TargTable & "] (BATCH) VALUES('x')",
RunSql1 = Value.NativeQuery(Source, Sql1),
Sql2 = "select count(*) from [" & TargTable & "]",
RunSql2 = Value.NativeQuery(Source, Sql2),
Result = RunSql1 & RunSql2
in
Result
When I refresh the query in Excel, the number of records increases by 2.
There are no other queries in my workbook.
What is causing this and how can I just insert 1 record?
Background/Use case: I want to refresh a SQL Server table with data from a text file that is in a complex format (from SAP). I'd like to use PowerQuery in Excel to graphically manipulate a text file that has data. Once I extract the needed data, I'd like to load the extracted data into SQL Server.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
