简体   繁体   English

如何将表从前端传递到存储过程?

[英]How to pass a table from frontend to a stored procedure?

I want to pass a table as a parameter to a stored procedure. 我想将表作为参数传递给存储过程。 Is it possible to do it. 有可能做到这一点。 Please give some example. 请举个例子。

In SQL Server 2008 you can use Table Valued Parameters - pass in a TABLE type as a parameter to a sproc. 在SQL Server 2008中,您可以使用表值参数 - 将TABLE类型作为参数传递给sproc。

I wrote up an article on the differences of the various approaches you could take, with a performance comparison here: CSV vs XML vs Table Valued Parameter 我写了一篇关于你可以采取的各种方法的差异的文章,这里有一个性能比较: CSV vs XML vs Table Valued Parameter

Solution to this 解决这个问题

Convert you datable in xml by using datatable.Writexml 使用datatable.Writexml在xml中转换数据

than pass this xml as string in stored procedure parmeter with the datatype Varchar(max) 将此xml作为字符串传递给存储过程参数,数据类型为Varchar(max)

Than use OpenXml to create datatable again form the xml string passed by you. 比使用OpenXml从您传递的xml字符串再次创建数据表。

See the example : http://msdn.microsoft.com/en-us/library/ms186918.aspx 请参阅示例: http//msdn.microsoft.com/en-us/library/ms186918.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM