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

x
?
Solved

Does an Excel 2007 table look like a real table to SQL Server?

Posted on 2011-02-24
4
Medium Priority
?
263 Views
Last Modified: 2012-05-11
I have a named Table in Excel 2007 called ACCT_List. It's a list of account numbers. I want to use the Excel Table to join to tables in our SQL Server 2005 environment to retrieve some data about these accounts.

With VBA, I can generate a long string containing all the account numbers and then query "WHERE SQLTable.Acct in (x,x,x,x,x,x,x,x,x,x,x,x,x,....)" That works fine, but seems a bit clunky.

I was hoping I could tell my VBA code that the Excel table is an actual "table", and be able to join the Excel Table with the SQL table with an inner join clause.

Is that possible? Maybe in Excel 2010??

Thanks!
0
Comment
Question by:notawahoo2
  • 2
4 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 200 total points
ID: 34977636
What you are trying to do is not possible. The reason is that SQL Server runs the query on the server running the the SQL server query engine which does not have access to your workbook which is open on your local machine. Even if the workbook was running on the server SQL Server still would not be able to do any operations with it unless it was imported into it's own SQL Server table.

What you can do is load the data into a SQL Server table and then proceed from there. However, this seems even more troublesome than creating a query and using a simple comma separated list of values with the "IN" operator.

Excel 2010 provides no such service or function.

Kevin
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 34977638
You should be able to use the OPENROWSET() function as explained in this article: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/A_3025-Retrieving-Data-From-Excel-Using-OPENROWSET.html
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 34977643
Good points Zorvek.

notawahoo2: please note that the SQL Server needs to be able to access your Excel file somehow using that OPENROWSET function.
0
 

Author Closing Comment

by:notawahoo2
ID: 34979284
Thanks so much, very logical explanation of how it actually works!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

824 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