Forum Discussion
Has the ability to refresh a dataset with a dynamic SQL stored procedure been disabled?
Up until today, I had a dataset that was able to be refreshed perfectly fine through the Service. This particular query has a single database as a source, which is an Azure Database. The dataset uses 4 queries to get data from the database. 2 which are views, and 2 which use Stored Procedures that take in a few parameters.
In the case of the Stored Prodedure, the parameters require a filter string and a Start Date/End Date for the returned rows. The dates change every day as its up until current.
Here is what my code calling one of the stored procedures looks like in Power Query:
Source = Sql.Database("<MyServerName>.database.windows.net", "<MyDataBase>", [Query="Exec Example.[sp_ExampleStoredProcedure] 0, " & fnStartDate & ", " & fnEndDate & ", 'EP231%'", HierarchicalNavigation=true, CommandTimeout=#duration(0, 0, 90, 0)]),(i've changed some names for privacy reasons)
The functions that make the parameters dynamic are:
let
Result = "'" & DateTime.ToText(Date.AddYears(DateTime.LocalNow(), -2), "yyyy") & "-01-01'"
in
Resultand
let
Result = "'" & DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd") & "'"
in
Result
When i check the service for this dataset, i no longer get the option to refresh the dataset, or even set "Connect directly". When i look at the refresh history, you can see where it previously worked and then it starts to fail today. If i remove the Stored Procedures from the dataset, i'm able to select "Connect Directly" again. I only found this coincedently when i went to make minor updates this morning to a report.
The error now stating:
Data source error:
Unable to refresh the model (id=1767871) because it references an unsupported data source.
Cluster URI: WABI-SOUTH-EAST-ASIA-redirect.analysis.windows.net
Activity ID: 725ea1be-d2db-4f55-ace8-9a91ccc4b307
Request ID: af57b3a0-5ce2-437a-aba8-2f8e6e08e1b8
Time: 2018-04-09 00:25:48Z
- Anonymous8 years ago
Microsoft have solved this on the backend and it is working again.
12 Replies
- AnonymousNot applicable
Further testing has shown that if i change the parameters to a literal, rather than a function, I'm able to use "Connect Directly" and do further refreshes.
Example as:
", "<MyDataBase>", [Query="Exec Example.[sp_ExampleStoredProcedure] 0, '2016-01-01', '2020-01-01', 'EP231%'", HierarchicalNavigation=true, CommandTimeout=#duration(0, 0, 90, 0)]),
- GilbertQ
Super User
Hi Ross, could it possibly be that the functions are not returning it as the right data type?- AnonymousNot applicable
GilbertQ its a good suggestion, however refreshing through the desktop produces no issue. The code is also unchanged since I created it early last month.
The only difference between today where it didn't work, and previous weeks where it had, was some simple changes to the front end reports. I've not actually made any backend changes.
I've taken some code out into isolation and uploaded a dataset with just a single table, the ability to select a refresh in the service is still no longer there.
Something to note: Whenever a refresh is required through the desktop, each new day does require a new set of authorized permissions. This has always been the case, however it never caused any problems with the online side of this. Part of me wonders if there is a security hole that has been patched?