Forum Discussion
TheMick15
6 years agoRegular Visitor
RAISERROR or THROW in Power Query Store Procedure for Custom Errors
I have around 4 Excel power query's that run a stored procedure in SQL Server. I'm using Azure SQL Database. I need to be able to do a check in the stored procedure, and raise an error if certai...
artemus
6 years agoMicrosoft Employee
There might be ssome delay loading happening. Try using:
Source = (try Sql.Database("myserver", "mydb", [Query="exec DBO.SP_MY_SP '" & Number.ToText(Project_ID) & "'"])[Value]),
TheMick15
6 years agoRegular Visitor
When I did this it changed my m to the following
let
Project_ID=Excel.CurrentWorkbook(){[Name="Param"]}[Content]{0}[#"Project_ID"],
Source = (try Sql.Database("MyServer", "MyDB", [Query="exec DBO.sp_my_sp '" & Number.ToText(Project_ID) & "'"])[VALUE]),
Value = Source[Value]
in
Value
Then it gives me a message saying "The column 'Value' of the table wasn't found.
This seems much harder than it should be, I wonder why RAISERROR or THROW don't just natively show an error like I would hope!
- artemus6 years agoMicrosoft Employee
Use [Value] not [VALUE}