Solved

Bulk Import Access Table to SQL Server

Posted on 2014-01-08
4
1,478 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
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Surendra Nath
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now