Solved

Fastest way to import textfile record into database

Posted on 2009-05-10
9
309 Views
Last Modified: 2013-11-07
Any fast and efficient way for a console to read from a textfile, do format checking and duplication checking on row then insert the record into database? i would like to read from 100k line and insert into database in a short time. expect to insert 100k row record in 5-10 minute.
0
Comment
Question by:mkdev2009
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 6

Expert Comment

by:nirojexpert
ID: 24351360
the fastest way is to load using the sql loader. you can enable your constraints of data validation and unique constraints using the database features.
but if your database is not oracle, you have to use the suitable tool.
the main point is the use the tool provided by the database than making your own if you are really concerned with performance.
0
 
LVL 7

Expert Comment

by:Alpha Au
ID: 24351367
if you are using sql server, the fastest way to import a text file to db is BCP

you may check this out.

http://msdn.microsoft.com/en-us/library/ms162802.aspx
0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24352654
Have you tried out the native loading techniques specfic to the databases.
Since you haven't specified your database, listing the options below:

1. SQL Server - BCP
2. Oracle - SQL Loader
3. DB2 - LOAD
4. Sybase - BCP
5. MySQL  - LOAD

By the way, these native loading techniques are the faster way to load text file into the appropriate tables.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:mkdev2009
ID: 24354461
Hi all, thanks a lot for the reply.
FYI, i am using MSSQL as my database. curretly the txt file is uplaod via web portal,and the console need to read it, do the validation, and insert into DB.
Any idea to speed up during duplication checking?

nirojexpert,
the duplicate validation are base on 3 criteria, dun think the unique constraints  able to do the checking.
0
 
LVL 28

Expert Comment

by:Bill Bach
ID: 24354765
An ETL tool may be quite helpful here, as well.  Pervasive Data Integrator (www.pervasive.com) can provide all of the text parsing, deduplication, and database insertion.  The real performance is in the automated processing of the "Engine", but you can certainly do all of what you need (except for automated runs from a batch file) via the less-expensive Developers Seat license.
0
 
LVL 7

Expert Comment

by:Alpha Au
ID: 24360421
if the speed is concerned, i would suggest to batch insert the txt file into sql server table (create a table for temp storage)
then run a sp to do the deduplication and validation.

0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
ID: 24360627
Since this is MS SQL Server, you can follow this procedure.

1. Create a temporary table with exactly the same structure as of your original table without any constraints.
2. BCP that flat file into a temporary table without any validation.
3. From the temporary table, INSERT / UPDATE records into your main table based along with the required validations.
4. Capture error records if any.

Hope this helps
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question