Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel VBA Insert multiple records using all or nothing approach

Hi

I need to insert a few hundred records of data into a SQL database using an all or nothing (or transact rollback) approach.
What Excel VBA code would I use to do this?
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

how do you insert the records? By doing multiple INSERT statements? In that case surround the block of statements by BEGIN TRAN / COMMIT TRAN.

Check https://docs.microsoft.com/en-us/sql/t-sql/language-elements/begin-transaction-transact-sql?view=sql-server-2017
Avatar of Murray Brown

ASKER

Thanks Eric. Do youboissibly gave an Excel VIA example? I will be looping through Excel rows and doing an SQL insert statement for each one
I don't have VBA samples, I thought you already your insert statements ready!
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada 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
Thanks very much Eric