?
Solved

Adding data to a table

Posted on 1998-07-09
8
Medium Priority
?
182 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
[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
  • 4
  • 4
8 Comments
 
LVL 7

Accepted Solution

by:
spiridonov earned 80 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

801 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