将数组传递给存储过程 [英] passing array to stored procedure

查看:87
本文介绍了将数组传递给存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试将整数数组传递给sql server 2008中的存储过程.我进行了一些研究,并且有一些基于xml的解决方案.有什么解决方案更容易吗?

非常感谢.

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.

推荐答案

您可以将数组转换为定界字符串,然后在存储过程中再次将其提取.
You could convert the array to a delimited string and extract it again in the stored procedure.
int[] arr = {0,1,2,3,0,1};
string result = arr.Aggregate("", (s, i) => s + ";" + i.ToString());


这里有一个很好的解决方案: ^ ]
There is a nice little solution here: Passing an array or DataTable into a stored procedure[^]


这篇关于将数组传递给存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆