0

Hi all,

I would like to export data from an Access DB, can this be achieved through a command? I plan to automate this export.

1
Contributor
1
Reply
9
Views
1 Year
Discussion Span
Last Post by RudyM
0

Simplest way I found was using a VB script:

Dim connStr, objConn, getNames, FSO

connStr = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\Me\Documents\Database1.accdb"

Set objConn = CreateObject("ADODB.Connection")
Set FSO = CreateObject("Scripting.FileSystemObject")

LogFile = FSO.CreateTextFile("C:\Temp\Base.txt")

objConn.open connStr

Set rs = objConn.Execute("SELECT * FROM BASE")

DO WHILE NOT rs.EOF
  LogFile.WriteLine(rs.Fields("id") & "," & rs.Fields("fname") & "," & rs.Fields("lname") & "," & rs.Fields("street"))
  rs.MoveNext
Loop

objConn.Close

Set rs = Nothing
Set objConn = Nothing

And then run a BCP import to SQL server on the output file generated.

Edited by RudyM: Added detail for clarification.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.