Forum Discussion
Error loading data
Does this EXACT text work in SSMS?
Not sure you can do complex statements, stuff with declared variables, etc. Maybe you should wrap this into a stored procedure in the database then run that proc from Power BI.
- Markzolotoy5 years agoImpactful Individual
It works perfectly in SSMS.
- ToddChitt5 years agoSuper User
Is the entire statement wrapped in double quotes? Is it its own Query?
I do this sometimes, create a query with something like:
" SELECT ... FROM...WHERE... "
Then have a second query with M code like this:
let
Source = Sql.Database(ServerName, DatabaseName, [Query=#"sql_text"])
in
SourceIs that what you are doing here?
- Markzolotoy5 years agoImpactful Individual
ToddChitt I have converted my code into SP and it's exactly same error. Smells to me like a PBI bug.
I am calling the store proc like this:
exec usp_GetAlerts_Summary_Counts 3, '.................'
Get this:
Microsoft SQL: Incorrect syntax near the keyword 'exec'. Incorrect syntax near ')'.
- Markzolotoy5 years agoImpactful Individual
ToddChitt I have copied code from the first query inot second and I get the same error. Looks like the bug is:
declare works only for one query.
Is there a PBI version without this bug?