Hello,
First of all, Merry Christmas to everybody!
I've faced with a problem, what currently I can't solve. I want to call stored procedure from an other database with some input parameters and want to store the result of the stored procedure in a variable. All this I want to do dynamically.
My idea was to store the sp in a table with its parameters, somehow like this:
The call of the sp would be done in an other sp which first reads the sp to be called from the table, then substitutes the @ParamXValue-s with actual values and then calls the stored procedure somehow like this
where @SpToBeCalled contains the stored procedure to be called with the substituted parameter values and @Result would contain the result of the stored procedure.
My problem is that, can't exec this way the sp, I got always error and it seems the MS SQL recognizes the value of @SpToBeCalled as a stored procedure name and says doesn't find such sp.
The above mentioned way is working well without parameters. Does anybody idea how could it be solved with parameters? Could it be solved at all?
Thank you in advance for any piece of ideas!
Regards,
VoiD
First of all, Merry Christmas to everybody!
I've faced with a problem, what currently I can't solve. I want to call stored procedure from an other database with some input parameters and want to store the result of the stored procedure in a variable. All this I want to do dynamically.
My idea was to store the sp in a table with its parameters, somehow like this:
Code:
[dbname].[schemaname].sp_my_stored_proc @Param1=@Param1Value, @Param2=@Param2Value
Code:
exec @Result = @SpToBeCalled
My problem is that, can't exec this way the sp, I got always error and it seems the MS SQL recognizes the value of @SpToBeCalled as a stored procedure name and says doesn't find such sp.
The above mentioned way is working well without parameters. Does anybody idea how could it be solved with parameters? Could it be solved at all?
Thank you in advance for any piece of ideas!
Regards,
VoiD