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 2005 Forums
 Transact-SQL (2005)
 Insert a List<string> parameter to s.procedure

Author  Topic 

skiabox
Posting Yak Master

169 Posts

Posted - 2009-09-15 : 08:15:43
I need to insert a List<string> parameter from my code (c#) to a stored procedure so that I can loop in the stored procedure with a function that accepts one parameter.
Is there any way I can do that?
Thank you!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-09-15 : 08:18:12
Is this for a CLR stored procedure inside your database?
Go to Top of Page

skiabox
Posting Yak Master

169 Posts

Posted - 2009-09-15 : 08:27:28
I have not created the stored procedure yet.
I have created two functions.
I need the stored procedure so that I can loop through my function, because this function accepts only one parameter and I want to pass from my code more than one parameter at once(that's why I use a List<string>)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-15 : 08:30:00
Are you trying to pass csv as parameter to the procedure?
If so, serach for Array+SQL Server in google

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

skiabox
Posting Yak Master

169 Posts

Posted - 2009-09-16 : 06:41:15
I've managed to find a Parameter To List function here :
http://www.experts-exchange.com/articles/Database/Miscellaneous/delimited-list-as-parameter-what-are-the-options.html

Now I am trying to use this function(dbo.ParmsToList) to call a function that accept only one parameter.
Any ideas on how to loop in the parameter list so that I can call the one parameter function?

Thnx!
Go to Top of Page

skiabox
Posting Yak Master

169 Posts

Posted - 2009-09-16 : 08:48:26
Should I use a cursor in my stored procedure so that I can loop in the incoming list of parameters and be able to call my one parameter function that returns a table in every loop?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-09-16 : 10:23:51
It might be better to describe what the function does and what kind of results you're expecting (posting code would help too). It could probably be modified to accept a list and return all the results in one call. This is far preferable than looping or cursoring in SQL Server.
Go to Top of Page
   

- Advertisement -