How to pass a 2D array to a Stored procedure?
I'm trying to pass a 2D array from by C#.NET
p开发者_运维问答rogram to a stored procedure in SQL Server 2005
. I dont know how to accomplish this. I'm gathering my data in a DataGridView
.
SQL Server doesn't support arrays as such.
Depending on how much data you have, you can do something like this: How to Pass and Handle a Delimited String similar to handling an Array() of Values.
You can also read Erland Sommarskog's article on the subject of Arrays and Lists in SQL Server 2005 which outlines various different approaches to tackling the problem.
At SqlServerCentral there's an excellent article by Jeff Moden on how to split a CSV list in Sql server. The tally table approach is also shown in the article by Erland Sommarskog, but this one seems to use slightly different concepts. So it might be worth comparing performance of the two.
精彩评论