[Webinar] Learn how to a build a cloud-first strategyRegister Now


Importing Multiple Worksheets On Excel To Single Table

Posted on 2011-05-11
Medium Priority
Last Modified: 2012-05-11
Began supporting a new production system quite recently, with SQL Server 2005 as backend. Had call from user today from user who was trying to import Excel spreadsheet via the SQL 2005 Importr/Export Wizard - user was trying to import all four worksheets from spreadsheet into single table in SQL Server 2005.

Import was failing with error message along lines of :

The same destination table name TARGETTABLE is used more than once. All destination table names must be unique.

User mentioned that they had been able to do this previously without any problems under their old SQL Server 2000 box - logged onto that box, and I was able to import all four worksheets from spreadsheet into single table in SQL Server 2005.

Any ideas on how this can be done in SQL 2005, given this apparent restriction in SQL 2005's Importr/Export Wizard.
Question by:raymurphy
LVL 15

Accepted Solution

Aaron Shilo earned 1000 total points
ID: 35739122
LVL 40

Assisted Solution

lcohan earned 1000 total points
ID: 35739137
You could import all sheets in different intermediate/staging tables then run in SQL server a INSERT into your single destination table a series of SELECT statements with UNION ALL in between from each of the intermediate/staging tables.

Author Comment

ID: 35740517
ashilo, this looks like something that will be worth trying.

lcohan, this approach is fine from a developer/dba perspective but would not be suitable for the end-users themselves.

Thanks for both comments.

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

865 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