当我使用SQLBulkcopy时从表中插入行 [英] Get inserted row from table when i am using SQLBulkcopy

查看:94
本文介绍了当我使用SQLBulkcopy时从表中插入行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将数据插入到两个表中。第一个表pimary键值将用于第二个表。我已经使用SQLBulkcopy插入数据。如何从第一个表中插入行而不提交transction.End仅代码我可以为这两个表提交。

非常紧急。

I have to insert data into two table.First table pimary key values wil be used for second table.I have inserted data using SQLBulkcopy.How can i get inserted row from first table without commit the transction.End of the code only i can give commit for thes two tables.
Very urgent.

推荐答案

如果您使用的是SQL 2005或更高版本,那么您可以使用OUTPUT插入查询中的子句。使用此功能,您可以访问魔术表(插入,删除)。请阅读此链接 http://technet.microsoft.com/en-us/library /ms177564.aspx [ ^ ]有关在插入语法中使用output子句的更多信息
If you are using SQL 2005 or higher then you can use OUTPUT clause in your insert query. Using this you can access the magic tables(inserted,deleted). Please read this linkhttp://technet.microsoft.com/en-us/library/ms177564.aspx[^] for more info on using the output clause in your insert syntax


这篇关于当我使用SQLBulkcopy时从表中插入行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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