Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Bulk Import Access Table to SQL Server

Posted on 2014-01-08
4
Medium Priority
?
1,778 Views
Last Modified: 2014-01-26
Hi,

What's the best to bulk import an Access table into SQL Server 2012?

I tried using this

SELECT * INTO [E2].[dbo].[Test]
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','C:\TEST.ACCDB';;, 'SELECT * FROM [Test]')

and it runs extremely slow.

Thanks.
0
Comment
Question by:akivashapiro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39766276
Are you doing this as a one-off exercise or are you trying to do this as part of an application?

Assuming Access 2003, If you are doing it as a one-off then try this:

     Open the table

     File (Menu) --> Export

     Save as Type 'Text Files'

Don't use the 'save formated' option

That will bring up the Export Text Wizard

     Choose Delimited, click next

     Choose 'Comma' delimiter and " as Text qualifier.

     Choose 'Include Field names on First Row' if you want column headings

     Click next

     Give it a name and click finish

That will give you a CSV file.

If you want to do it as part of the application take a look at docmd.TransferText in MS Access help.

once you do the above steps and get the CSV file out,
Then you can either bulk insert or BCP commands to load them into your table pretty fast.
0
 

Author Comment

by:akivashapiro
ID: 39766355
I'm doing this as part of an application, but I'd much rather use a Transact-SQL statement to import the data directly from the Access table into a SQL Table. Please advise. Thanks.
0
 

Accepted Solution

by:
akivashapiro earned 0 total points
ID: 39798759
I solved this by Exporting the access table to a tab delimited text file and importing into SQLServer using Bulk Insert:


BULK INSERT dbo.tbl FROM 'TEMP.txt' WITH (FIELDTERMINATOR = '\t',ROWTERMINATOR = '\n')
0
 

Author Closing Comment

by:akivashapiro
ID: 39809850
It was the only option I could find. I worked very quickly - over a million rows export and import in less than a minute. But, you have to deal with data anomalies, such as hidden characters, prior to exporting to text.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question