Can a procedure be created that takes any number of parameters?

I am having to debug a procedure that is called by a control in javascript that I do not have any control over accept for setting the procedure name to call.

I matched my parameters to my procedure to what I define as the parameters list, but somehow I keep getting a too many parameters specified.

If I had control over it in C# it would be easy to select which params are actually being sent, but I would like to give a procedure name to call and I can log the parameters sent somehwhere if anyone tells me how to do.

Thanks

August 28th, 2015 12:15pm

No but you can create a procedure with parameters that have default values. When executing a procedure that has defaulted parameters, it is not necessary to supply the parameter value. It will simply fall back to the default.

You could create a few "Dummy" varchar parameters to catch the extra values that the java script is passing.

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 12:43pm

Try passing in xml. That will have the same effect.

Carl

August 28th, 2015 12:44pm

Good day,

A procedure can have only constant number of parameters but you can use a parameter that include as many parameters as you want (if you are developer that you can think about passing a table as parameter).

The best solution to pass dynamic unlimited number of parameter is using Table-Valued Parameter (TVP).It is supported by .Net framwork so if you are developing in C# you can use it directly, but it is not supported by all other tech/language (like JAVA).

There are other option passing multiple parameter in one value. as other mention XML and JSON is a good example. In this article you have some more option: Representing list of values using a single value

* again, if you can use TVP then this should be your first chose.

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 1:04pm

Thanks everyone, this issue can be deleted.

I solved my issue by finding the old proc and adding the params that are no longer needed.

I was hoping there was a parameter array possible, but I no longer need it.

August 28th, 2015 1:41pm

Hi,

We do not delete thread without a really good reason :-)

It is great that other people will be able to see what was your case and how you solved it. In this case we could not help you and you helped yourself :-) So.. You can mark your own answer as the answer to the question in order to close the thread

* masrking yourown response as answer will not give you points, but will close the thread

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 5:24pm

Thanks everyone, this issue can be deleted.

I solved my issue by finding the old proc and adding the params that are no longer needed.

I was hoping there was a parameter array possible, but I no longer need it.

August 28th, 2015 5:40pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics