Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL: using function as parameter to a stored procedure [duplicate]

I am trying to use a function to pass a parameter to a stored-procedure.

But this:

exec stpMySTP dbo.fn_MyFunction(123)

generates an error:

Incorrect syntax near '.'.

Is it not possible to use a function when passing parameters to a procedure?

like image 372
yaronkl Avatar asked May 26 '26 11:05

yaronkl


1 Answers

You cant pass it directly to stored procedure. Declare first variable, set it to your function and then pass it to the procedure.

  DECLARE @pom [return type of function];
  SET @pom = dbo.fn_MyFunction(123);

  EXEC stpMySTP @pom
like image 139
Gane Avatar answered May 30 '26 21:05

Gane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!