Parameters to SQL

Martinl

New member
Joined
Dec 2, 2016
Messages
15
Reaction score
0
Points
0
Excel Version(s)
2016 MSO (16.0.9126.2259)
Hi

I picked up some code a few years ago to pull in SQL data using a parameter table in EXCEL
This worked quite happily until we decided to move outr server to the cloud and changed server names.

I thought that the change would be quite simple
Go to the table and change the server name and hey presto.
But no...I get nothing back.

I have check the parameters
dbServer CORRECT
dbName CORRECT
dbQuery CORRECT

If I click on each of these parameters in Power Query they all bring back the correct information but the Source line returns nothing and I cant understand why
By going to SQL the Query line reports as expected - so what am I missing?

this is my code
let
//Pull in a values from the parameter table
dbServer = fnGetParameter("Server"),
dbName = fnGetParameter("Database"),
dbQuery = fnGetParameter("SQL Statement"),




//Get the data
Source = Sql.Database(dbServer,dbName,[Query=dbQuery]),
in
#"Source"
 
Hi

I picked up some code a few years ago to pull in SQL data using a parameter table in EXCEL
This worked quite happily until we decided to move our server to the cloud and changed server names.

I thought that the change would be quite simple
Go to the table and change the server name and hey presto.
But no...I get nothing back.

I have check the parameters
dbServer CORRECT
dbName CORRECT
dbQuery CORRECT

If I click on each of these parameters in Power Query they all bring back the correct information but the Source line returns nothing and I cant understand why
By going to SQL the Query line reports as expected - so what am I missing?

this is my code
let
//Pull in a values from the parameter table
dbServer = fnGetParameter("Server"),
dbName = fnGetParameter("Database"),
dbQuery = fnGetParameter("SQL Statement"),




//Get the data
Source = Sql.Database(dbServer,dbName,[Query=dbQuery]),
in
#"Source"

https://www.excelguru.ca/blog/2016/04/28/pass-parameters-to-sql-queries/

This was a very strange situation.
It appears that there was an issue at the SQL server side which our DBA's dealt with after a quick call.
Not sure how this may help anyone but in case it does, I received this email back from the DBA's this morning.
"I have added two dependent tables on it [the Database, I assume] and enabled them"
 
Last edited:
Back
Top