Like in COALESCE function. You can pass one or more parameters.
The short answer would be no, it's not.
(there is a hard limit on # parameters, but if you ever get there, you're in deep trouble most likely)
Why would you need it? Don't you know beforehand what the procedure will do?
There is often a higher cost in reaching for the ultimate in generic, instead of specializing, which will do 'less' but with lower overhead and less test/development/maintenance time.
Keep it simple, and it will work forever =:o)
/Kenneth
|||Nope, you can't even write a function like that where you can skip parameters. I have a date function that I need to be able to pass "unlimited" values to but I have only 16 works right now. Even worse you would have to default every parameter too.
dbo.function ('value1','value2',null,null,null,null,null,null,null,null,null,null,null,null,null,...)
As an alternative (yet more costly method) you could pass a comma delimited list as a string parameter and split it up into your N values. If that is a reasonable possibility, then you can look here for how to do this: http://www.sommarskog.se/arrays-in-sql.html. XML is another possibility. Both of these require work on your end to compile the string of course, so that might not be a great way to go either.
If that doesn't make sense, someone here can write you a query based on the data you have.
|||I believe you can create an extended stored procedure that can take an unlimited number of parameters.|||Maybe You know how?Some example?|||
Extended stored procedures are marked for deprecation so don't plan on writing new code since you will have to convert again in couple of releases or so. What is the problem you are trying to solve? Why do you need to pass optional parameters? You could also use a temporary table for example to pass the parameter values as rows. So it depends on what functionality you want and why.
|||My question is purely teoretical. There is no some kind of problem I'am trying to solve with this solution.
No comments:
Post a Comment