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
Oh I think I get what your saying... you want to handle an error from SQL and give it to the user.
In that case it would be something like:
let
Result = (try <Your SQL sproc call>),
HasError = Result[HasError],
ErrorMessage = Result[Error][Message],
ErrorDetails = Result[Error][Detail],
ValueNoError = Result[Value]
in
if HasError then ErrorMessage else ValueNoError
You can also do more in depth info checking with ErrorDetails.
TheMick15
6 years agoRegular Visitor
Sorry, was away for a bit. Trying this now, will update on results!