1

We are migrating to Access 2013 from 2010 and from SQL Server 2008 to 2016. To import a CSV file, I used the Docmd.TransferText command and that did the import easily as it was to a local Access table.

Now I have issues when trying to import the data from CSV to a remote SQL Server table. I copied the file to the SQL Server box where the 2016 database is and used the below for the transfer.

str1 = "BULK INSERT Temp3 " & _
          "FROM 'C:\Bulk\FileExchange_Response_49636101_49.csv'" & _
          "WITH (FIRSTROW = 2, FIELDTERMINATOR = ',', " & _
          "ROWTERMINATOR = '\\n', TABLOCK)".

This does not throw any error however, does not import the data.

Could anyone please shed any ideas to import the data from the CSV?

Thanks

The data does not get imported even if there are no errors.

2
  • Have you considered using Power Shell to import the CSV file instead of MSAccess? Commented Jun 10, 2019 at 21:17
  • So what does it do? I suggest you run it directly in SSMS directly rather than running it in VBA. VBA might be asynchronous. Commented Jun 10, 2019 at 23:03

1 Answer 1

1

Looks like you got your data into Access. Try this:

  1. Create a "Linked Table" to your SQL Server table. External Data > New Data Source > From Database > SQL Server > Link to the data source by creating a linked table > Create a DSN to your database, choose your table. You'll see a green icon in the tables with your SQL Server table there.
  2. Create an Append Query. Create > Query Design > Close Show Table pop-up > Select SQL view at top left > use something like Insert Into MyNewLinkedTable (Field1, Field2) Select Field1, Field2 From MyAccessTable
  3. Click Run on the ribbon above, then follow the prompts.

No VBA required!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.