Solved

Fastest way to import textfile record into database

Posted on 2009-05-10
9
305 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
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
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…

840 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