View Full Version : Using VBS to execute external sql scripts in Access


Launch_Pad
08-24-2010, 02:16 AM
Hi,
This is my first post so please excuse my ramblings and potentially daft novice questions.
I am trying to make a script that can run external textfile sqlscripts from an external script on an Access DB (preferably 2003 but Im willing to compromise on this).
I can run an external sqlscript from VBA within Access.
I can run an internal piece of code from a VBS script.
Can anyone explain how to run an external sqlscript from VBS (or some other batch mechanism) into access.

(FYI the source of my problem is several hundred sql and batch processed files previously used on an Oracle DB that now need to be converted to Access to simplify a very labourious and potentially error strewn process).

dim accessApp
set accessApp = createObject ("Access.Application")
accessApp.OpenCurrentDatabase ("C:\TEST.mdb")
accessApp.Run "C:\blah.sql"
accessApp.Quit
set accessApp = nothing

The run bit doesnt work, tried execute etc - but I suspect Im barking up the wrong tree - any suggestions.

Thanks
Launch_Pad.