Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi all,

I am trying to pass an array of integers to a stored procedure in sql server 2008. I had some research and there are some solutions xml based. Is there any solution easier?

Thanks a lot.
Posted

You could convert the array to a delimited string and extract it again in the stored procedure.
C#
int[] arr = {0,1,2,3,0,1};
string result = arr.Aggregate("", (s, i) => s + ";" + i.ToString());
 
Share this answer
 
v2
Comments
kurtiniadiss 15-Oct-11 4:56am    
Thanks Andre, can you recommend any web site or have any useful code on this since I am new in this job:)
André Kraak 15-Oct-11 5:08am    
Have a look at this (http://weblogs.sqlteam.com/dinakar/archive/2007/03/28/60150.aspx) on how to split the string at the stored procedure side.
kurtiniadiss 15-Oct-11 5:19am    
wonderful!
kurtiniadiss 15-Oct-11 5:37am    
Andre, I have a last question. Is there a limit for the number of elements in the array. I mean, can I parse 1 million integer from @array
André Kraak 15-Oct-11 5:39am    
For that you probably need the solution OriginalGriff supplied.
There is a nice little solution here: Passing an array or DataTable into a stored procedure[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900