如何在SQL Server中进行批量增补? [英] How do I do batch upserts in SQL Server?
本文介绍了如何在SQL Server中进行批量增补?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用MERGE
语句在sql server 2008数据库中插入行.但是,我的sproc是单行操作,而实际上我更喜欢对它们进行批处理.甚至有可能吗?如果可以,我该怎么办?
I'm using the MERGE
statement to upsert rows in an sql server 2008 database. However, my sproc is a single-row operation, whereas in fact I'd prefer to batch these. Is this even possible and, if so, how do I do it?
推荐答案
可以在proc中使用表值参数吗?在此处查看 http://www.sommarskog.se/arrays-in -sql-2008.html#TVP_in_TSQL 以获得一些想法
Can you use Table-Valued Parameters in your proc? Take a look here http://www.sommarskog.se/arrays-in-sql-2008.html#TVP_in_TSQL to get some ideas
然后在proc中,您可以对TVP使用MERGE
Then in the proc you can use MERGE against the TVP
这篇关于如何在SQL Server中进行批量增补?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文