Solved

Adding data to a table

Posted on 1998-07-09
8
177 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
 
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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 utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now