How to raise exceptions in a subquery?

Hi TG Team,

I tried to raise exceptions in a subquery; however, putting the RAISE before RETURN statement threw me error : “Query xxx must return a value!”.

How should I cope with that? thanks.

It seems like you cannot raise exceptions in subqueries that are written to return some value. Intuitively, this kind of makes sense because if your subquery fails then your main query will end up failing as well.

I would recommend looking further into the Exception Docs for alternative workarounds.

Perhaps your queries can be re-written with PRINT statement output instead to allow for exceptions.

1 Like