Solved

Adding data to a table

Posted on 1998-07-09
8
179 Views
Last Modified: 2010-03-19
What is the quickest way to add data to an sql table. In jet, I would do the following
do while !eof(source)
tbl.addnew
tbl!fld1 = data1
tbl!fld2 = data2
tbl.update
loop

I am not sure how to do this in SQL efficiently. I am doing it with a SQL RDO and opening an rdoresultset, and using the same procedure outlined above, but it is **very** slow.  I am not sure what direction to take.
0
Comment
Question by:redbaron082997
  • 4
  • 4
8 Comments
 
LVL 7

Accepted Solution

by:
spiridonov earned 20 total points
ID: 1091707
use insert into table_name (col1,col2...) VALUES (val1,val2...)
0
 
LVL 7

Expert Comment

by:spiridonov
ID: 1091708
You do not need to open recorset to do that you can execute it as pass-through query.
0
 
LVL 1

Author Comment

by:redbaron082997
ID: 1091709
Ok, but how would it work in a scenario that I am reading a text file (warning* it is very huge. Every day I am adding 100,000 records), and adding those values, to the table?
right now, I do the following
readNextLine( inFile,InText)
db.addnew
db.fld1 = getfld(1,inText)
db.fld2 = getfld(2,intext)
etc..
db.update

I am increasing the points. Thanks
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 1

Author Comment

by:redbaron082997
ID: 1091710
Would a stored procedure be worth it? Since this is a task that is done every single day, and generally the information that needs to be added is available only 1 hr before the time that it is needed,I need to optimize everything!!! Thanks
0
 
LVL 7

Expert Comment

by:spiridonov
ID: 1091711
If you are reading from text file you should look at using bcp programm which is designed to load text data into SQL server it is console (text) mode program and it will be the fastest solution to use , much faster then any insert.
0
 
LVL 1

Author Comment

by:redbaron082997
ID: 1091712
I have been looking at that ,and you are right. Much faster. Is there any way to implement this kind of speed without using BCP? are the SQL calls available to VB that BCP is using?
0
 
LVL 7

Expert Comment

by:spiridonov
ID: 1091713
BCP is using a set of DB-library functions created specificly for the  purpose of loading text files,I'm not sure if you can use them from VB. You probably should ask such question in VB area.
0
 
LVL 1

Author Comment

by:redbaron082997
ID: 1091714
Thanks for the help!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with Merge Join and Conditional Split in SSIS 6 80
SQL SERVER - Index skipped a number 2 26
SQL USE DATABASE VARIABLE 5 27
SQL 2012 clustering 9 11
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

856 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