从csv文件导入数千条记录 [英] Importing Thousands of records from csv file
问题描述
大家好,
我想从csv文件中导入数千条记录,同时我还需要管理在子表中插入数据的父子关系。
我使用SQLBulkCopy来导入数据,而且在性能方面它很快。
但是我无法管理父子关系用于在两个不同的表中插入数据。
可以任何人指导我怎么可能?
或者还有其他方法可以这样做除了SQLBulkCopy?
MY要求IS:我想使用Parent Child关系导入数千条记录(性能是关键点)。
请提供建议。
谢谢,
Rajan Bajania
Hi All,
I want to import thousands of record from a csv file and same time I also need to manage parent child relationship for Inserting Data in tables.
I have used SQLBulkCopy to Import data, and in terms of performance its fast.
But I am not able to manage parent child Relationship for Inserting Data in two different tables.
Can Any one guide me that how can its possible ?
or is there any other way to do this except SQLBulkCopy ?
MY Requirement IS : I want to Import thousands of records using Parent Child relationship (performance is key point).
Please provide suggestions.
Thanks,
Rajan Bajania
推荐答案
一个快速建议是使用SQLBulkCopy导入临时表中的所有记录。导入所有记录后,执行一个存储过程,该存储过程首先导入父记录,然后从临时表导入子记录,并使用相对于父表的更新引用键
One quick suggestion is to import all the records in a temporary table using SQLBulkCopy. Once all records gets imported then you execute a stored procedure who first import parent records and then import child records from temp table with updated reference keys with respect to the parent tables
然后你必须尝试有点像SSIS(SQL Server集成服务)谷歌你有很多信息可以获得你的解决方案
Then you have to try some thing Like SSIS(SQL Server Integration services) Google it you have lot info you will get for your solution
这篇关于从csv文件导入数千条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!