Link to home
Start Free TrialLog in
Avatar of redbaron082997
redbaron082997

asked on

Adding data to a table

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.
ASKER CERTIFIED SOLUTION
Avatar of Victor Spiridonov
Victor Spiridonov
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You do not need to open recorset to do that you can execute it as pass-through query.
Avatar of redbaron082997
redbaron082997

ASKER

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
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
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.
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?
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.
Thanks for the help!!