VBA/DAO: Inserting MANY rows of data from a range into a SQL Server table

jjasmith4

New Member
Joined
Aug 22, 2018
Messages
48
I know -- ADO is much better for many reasons, but for various political reasons I have to use DAO.

Anyway, I've written VBA/DAO code which inserts from a range to a SQL Server table one row at a time. It's cumbersome, because I have to slap together an INSERT INTO table (columns) VALUES (expressions) statement for each row, and it's slow, because I have to throw lots of INSERT statements at the database. I've even tried beginning and committing a transaction, but it's still slow.

There's GOT to be a way to do it in one shot, i.e., the reverse of the Range.CopyFromRecordset method. Isn't there?
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Watch MrExcel Video

Forum statistics

Threads
1,099,013
Messages
5,466,020
Members
406,461
Latest member
Garrus

This Week's Hot Topics

Top