我们可以通过数据表来存储过程吗 [英] can we pass datatable to store procedure
本文介绍了我们可以通过数据表来存储过程吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我有点困惑,我们能否传递完整的数据表或数据集来存储过程
以及如何在存储过程中使用它.
amit jamwal
hi
i m little bit confuse that can we pass complete datatable or dataset to store procedure
and how to use it in store procedure.
amit jamwal
推荐答案
请参阅下面的链接.可能会对您有帮助.
http://beyondrelational.com/modules/2/blogs/28/posts/10441/passing-a-data-table-to-a-sql-server-2005-stored-procedure.aspx [使用SQLServer Management将数据从数据表复制到SQLServer数据库对象和SqlBulkCopy [ ^ ]
将数组或DataTable传递到存储过程中 [ ^ ]
Hi,
See the below link. It might be help you.
http://beyondrelational.com/modules/2/blogs/28/posts/10441/passing-a-data-table-to-a-sql-server-2005-stored-procedure.aspx[^]
Copy Data from a DataTable to a SQLServer Database using SQLServer Management Objects and SqlBulkCopy[^]
Passing an array or DataTable into a stored procedure[^]
这些链接可能会对您有所帮助.
将数据表发送到存储过程 [ ^ ]
将数据表传递到SQL Server中的存储过程2008 [ ^ ]
http://weblogs.asp.net/jgalloway/archive/2007/02/16/passing-lists-to-sql-server-2005-with-xml-parameters.aspx [
Hi,
these links may help you..
Sending a DataTable to a Stored Procedure[^]
Passing a datatable to a Stored Procedure in SQL Server 2008[^]
http://weblogs.asp.net/jgalloway/archive/2007/02/16/passing-lists-to-sql-server-2005-with-xml-parameters.aspx[^]
And use MERGE to update the EMP table inside the stored procedure...
Thank you
是的,您可以将数据表传递给SP,但是首先您需要在SQL Server中创建用户定义的表类型,其结构与要传递的数据表相同.例如:
yes u can pass datatable to SP, but first u need to create a user-defined table type in SQL server, having same structure as datatable to be passed. For eg:
CREATE TYPE TypeName AS TABLE
(
col1 int,
col2 varchar(50)
)
然后在SP参数中,使用类型"TypeName".
如果您使用C#,则在将数据表传递给SP时,请使用SqlDbType.Structured.
then in SP parameter, use type "TypeName".
If u r using C#, while passing datatable to SP, use SqlDbType.Structured.
这篇关于我们可以通过数据表来存储过程吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文