本文介绍了SQL批量插入/更新策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 原始问题: 您好, 我有一个字典<字符串>比方说20-60项。 数据库中的我有3列表: 1. key,2.item_key,3 .item_value 我需要做的是通过字典中的数据创建/更新该表中的数据。 我的问题是您选择保存数据的策略是什么? 我的想法如何做: 1. for cycle在单独的Sql插入/更新命令的事务中 - 不确定这是不是一个好主意,我认为必须有更好的方法如何做到这一点 2批量插入,我真的没有太多批量操作的经验,当我还需要更新而不仅仅是插入时可以做到这一点吗? 3.SqlDataAdapter?不知道怎么做... 你认为这最好的是什么? 编辑问题: 我决定更多地指出我的问题,因为有些解决方案是你的建议并不完全符合我的情况。不过我要感谢大家的想法,我也会提供我的工作解决方案。 问题: 我有一个SQL server 2005,我需要从c#dictionary插入/更新20-60项到我的数据库中。这样做的最佳策略是什么?解决方案 Original question:Hi,I have a Dictionary<string,> with let say 20-60 items.in database I have table with 3 columns:1. key, 2.item_key, 3.item_valuewhat I need to do is to create/update data in that table by data from dictionary.My question is what strategy would you choose to save data?My ideas how to do it:1. for cycle in transaction with individual Sql inserts/updated commands - not sure if that is a good idea, i think that there has to be some better way how to do it2. bulk insert, I don't really have to much experience with bulk operations would it be possible to do it when I also need sometime update not just insert?3.SqlDataAdapter? no idea how to do it...What do you think that would be best?Edited question:I decided to specify my question little bit more, because some of the solutions that you suggested doesn't exactly fit to my situation. However I'd like to thank you all for your ideas and I will also provide my working solution.Question:I have a SQL server 2005, and I need to insert/update 20-60 items from c# dictionary into my database. What would be the best strategy to do that? 解决方案 这篇关于SQL批量插入/更新策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-06 02:48