Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

loading related tables from a .xls

Posted on 2011-02-17
2
Medium Priority
?
946 Views
Last Modified: 2012-05-11
How would you load related tables from one excel spreadsheet..

Basically this from one .xls


Market                                   phone
Atlanta                                 555-435-6789
Atlanta                                 555-789-3456
Orlando                                444-678-5677
Orlando                                456-678-5432
Miami                                   333-678-9876


Needs to go into two tables obviously linked

Market Table

1      Atlanta
2      Orlando
3      Miami

Phone table
1      555-435-6789
1      555-789-3456
2      444-678-5677
2             456-678-5432
3      333-678-9876


Trying to use two data flows and a lookup I can’t figure out how to load the cities only once coming from a spreadsheet.. If I could do that, I could just use a lookup to load the marketed in the phone table..

Any ideas?
0
Comment
Question by:Gray5452
2 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 2000 total points
ID: 34918553
How to use Excel with SQL Server linked servers and distributed queries
http://support.microsoft.com/kb/306397


--Use a Linked Server
--To simplify queries, you can configure an Excel workbook as a linked server in SQL Server. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
--Q306397 HOWTO: Use Excel with SQL Server Linked Servers and Distributed Queries
--The following code imports the data from the Customers worksheet on the Excel linked server "EXCELLINK" into a new SQL Server table named XLImport1:
SELECT * INTO XLImport1 FROM EXCELLINK...[Customers$]
--You can also execute the query against the source in a passthrough manner by using OPENQUERY as follows:
SELECT * INTO XLImport2 FROM OPENQUERY(EXCELLINK,
    'SELECT * FROM [Customers$]')


--Use Distributed Queries
--If you do not want to configure a persistent connection to the Excel workbook as a linked server, you can import data for a specific purpose by using the OPENDATASOURCE or the OPENROWSET function.
--The following code samples also import the data from the Excel Customers worksheet into new SQL Server tables:
SELECT * INTO XLImport3 FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\test\xltest.xls;Extended Properties=Excel 8.0')...[Customers$]

SELECT * INTO XLImport4 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\test\xltest.xls', [Customers$])

SELECT * INTO XLImport5 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\test\xltest.xls', 'SELECT * FROM [Customers$]')
0
 

Expert Comment

by:SrinivasRavi
ID: 34931655
Hi Lcohan,
When i am trying to execute the distributed queries i am getting the following error.

"Msg 7403, Level 16, State 1, Line 2
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered."

Please let me know how to fix it.

0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline

886 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