Run the Stored Proc using the Parameter value from table

Hi Everyone..

Need help again.. :slightly_smiling_face:

I have this table:

Parameter Name Parameter Value Description
Mode 1
Name test01
SP_01 1 1-Run , 0 =Skip

As you can see all my SP parameters stored in a table.

Now.. I have SP_01, value=1 means it will run using the value from Mode=1 and Name='test01'

this is how it looks like:

execute SP_01 mode,name

You think this is possible??

Thank you in advance.

Why would you need to do this? you could have them as optional parameters and then handle within the code. I'm still trying to work out the scenario that this is used. Can you add more information?

1 Like

You do this a couple of different ways.

  1. Have the proc itself look up the param value(s) based on a control value. That is, add another column to give the parameters table a unique column value, such as identity or a code, then pass that value into the proc so it can retrieve the other param values based on that.

  2. Use the "standard" XML string concatenation to generate the string to exec the proc with parameters from the table, then exec that string.

Hi mike01
Thank you for your response...

Well, I want to simplify my codes and to manage my parameters in one table. And I want to do it in a dynamic sql... :slightly_smiling_face: