Results 1 to 3 of 3
  1. #1
    newbie30 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2017
    Posts
    15

    Import from CSV to a SQL table on a remote server using VBA Access

    Hello All,


    We are migrating to Access 2013 from 2010 and from SQL 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 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

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I haven't used that method, but I assume it's run via a passthrough query? It doesn't appear the spacing will be correct. Try this to see the finished string:

    http://www.baldyweb.com/ImmediateWindow.htm

    and test it directly on the server. To my eye it needs a space before WITH.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Why not link the remote SQL table back to your Access front-end and use the same method as before?

    Cheers,
    Vlad

Please reply to this thread with any new information or opinions.

Similar Threads

  1. ODBC with remote path to server
    By jaryszek in forum Programming
    Replies: 3
    Last Post: 06-01-2018, 04:19 AM
  2. Replies: 2
    Last Post: 03-30-2012, 02:37 AM
  3. Replies: 3
    Last Post: 02-23-2012, 07:16 PM
  4. Table fetching remote server
    By Manotosh in forum Access
    Replies: 2
    Last Post: 10-26-2011, 09:38 AM
  5. Getting date/time from remote server
    By mxfrail in forum Programming
    Replies: 4
    Last Post: 09-21-2009, 07:26 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums