将数据从 Excel 加载到 SQL DB
我在一张 xls 中有表格数据。我需要将此数据“更新”到 SQL DB 中的表中。
注意:
xls 将仅包含将发生更改的列。 (例如,如果只有两列将发生更改,则 xls 中将只显示所有记录的这两列)
主键列将出现在 xls 中以供参考。
请帮我解决这个问题。
I have table data in a sheet of xls. I need to 'update' this data into a table in SQL DB.
Note:
The xls will contain only the columns that will undergo change. (for example if only two columns will undergo changes, then only those two columns for all the records will be present in the xls)
The primary key column will be present in xls for reference.
Please help me in solving this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是一次性加载,那么将数据转换为 SQL 语句就非常容易了。假设您的工作表有两列(A 和 B),那么您可以将以下公式放入 C 列中:(
根据需要对字符串的引号进行排序等)
接下来只需将公式复制到底部,然后复制 col 中的所有单元格C、粘贴到文本编辑器中并运行 SQL 工具。
如果您需要将其交给用户或经常运行,那么有很多很多方法可以做到这一点,这实际上取决于您可以使用的工具(Java、C#...)
If this is a one-off load then it is pretty easy to turn the data into SQL statements. Say your sheet has two columns (A & B) then you could put the following formula in column C:
(sorting out quotes for strings, etc as appropriate)
Next just copy the formula down to the bottom, then copy all cells in col C, paste into a text editor and run into your SQL tool.
If you need to hand this over to users or run frequently then there are many, many ways to do this and it really depends on the tools at your disposal (Java, C#, ...)