Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Passing variable number of parameters to a stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-03-12 : 08:23:42
Kumar writes "To a stored procedure, I want to pass a variable number of parameters. That is, sometimes I would like to send only 2 parameters, sometimes 5 parameters, sometimes 3 parameters etc... The total number of parameters are not fixed.

Is this possible? If yes, can anyone please let me know how is this possible"

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-03-12 : 08:28:14
Why? What are you going to do with the variables? Is there a max number? Tell us what the purpose is and we can probably help you more.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-03-12 : 08:30:52
You can pass multiple values as a comma-separated value (CSV) string, and parse them inside your stored procedure. These articles should help:

http://www.sqlteam.com/searchresults.asp?SearchTerms=csv

But as Derrick suggested, we need to know more about what you're trying to do before we can offer a real solution.
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2004-03-12 : 10:48:36
Hey Rob, changed your mind on shots in the dark

I might get cursed here on this site, but I like this article http://www.sommarskog.se/arrays-in-sql.html

--Frank
http://www.insidesql.de
Go to Top of Page
   

- Advertisement -