How to increase bulk insert/select speed?

Today, I am writing a vc++ console application to insert 10000 records ,
totally 1x10E7 bytes, to mssql 7.0 server.  Surprisely, the speed is
about 29Kbytes per second.  
However, by ftp or copying the same
number of bytes to the server, i
got 2900Kbytes per second.  A 100
times different!!!

I have chose "select into/bulk copy" in the database property. But no help.

Can I increase the speed of bulk insert
or bulk select from the server?

Or my program which using COM is slow?

my source code look like this :

void main()
_ConnectionPtr m_pConnection;
_CommandPtr m_pCommand;



m_pCommand->CommandText = "insert mytable values ('xxxxxx......') "

for (i=0;i++;i<10000)

printf("duration is %2.1f",finish - start);

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alanpongAuthor Commented:
Edited text of question.
alanpongAuthor Commented:
Edited text of question.
Right the data to a text file and then use BCP, or you can use the db library directly and use BCP that way.
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

alanpongAuthor Commented:
i use the sql oledb provider, not the
odbc driver.
alanpongAuthor Commented:
do you mean in order to gain faster
performance, just bypass the ADO
layer and go directly to db library?
(I like ADO which makes coding more easier. :>)
Anyway, i will try bcp first
because bcp is written by dblib(?)
If bcp work fast, then dblib should
work fast too....
tell you the result later....
The other thing is the nature of the logging using BCP. it is greatly reduced.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alanpongAuthor Commented:
Wow.  Bcp reports about 2044 kbytes
per second!  Speed increaes a lot.
Please help me
I’m facing the same problem.
I used ado recordset with batchupdate and execute method of an ado connection with a block of inserts or SP (that perform the insert), to insert blocks of 10000 records and every insert took more then half a second.

When using BCP from a file it took me about 0.2 seconds for 10,000 this is steal to slow for me.

Can you please tell me what did you use at the end?
Did you find away to use dblib? If so please send me a sample code ????

alanpongAuthor Commented:
finally, i did what simonsabin told.
I didn't try dblib.

if u think BCP is still slow,
theorectially, to get faster transfer rate, we should do lower lever thing.
So, the workaround would be : programming a client with winsock, transferring the text data to sql server via TCPIP, bypassing the db library layer.

In the sql server, programming a server to import the text server.

But, if sql 7.0's "import and export wizard" is a COM component, we can make use of it without inventing any new thing.  (i didn't try whether it is faster or slow.)

Th fastest method of transfer is to use the BULK INSERT command in TSQL (slightly faster than BCP)
To speed it up ensure
No indexes on table
No Constraints on table
Data file is on different disk to that of the database data file.
Log file is on different disk as well
Database is already big enough to take the data i.e. it does not have to grow to accommodate the data.
Increase the Max Async IO configuration of the server, if using RAID.
Get faster disk
If using RAID get more disks to use in the RAID array.
If not use more disks and spread database across a file on each disk.
Get more processors
Get faster processors
Have everything on the server i.e eliminate network bottleneck

Thanks  simonsabin
Most of that is already set will the set the rest of the options and check the bcp again.

Do you know of way to get similar results of BCP import without using a file?

Thanks alanpong
Im going to look into the DTS Objects
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.