Skip to content
Advertisement

SQL Exit scalar function prematurely

In SQL, you can exit the stored procedure prematurely with RETURN statement.

However, when I try to apply the same principle to the scalar function, it returns the error, since function needs to return something.

How do I prematurely exit the scalar function the same way RETURN is used in the stored procedure?

Thank you.

Advertisement

Answer

You can’t RAISERROR or THROW in a function either. It sounds like you really want a stored procedure with an output parameter or a resultset.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement