Solved

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

Posted on 2011-02-24
4
258 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
[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
  • 2
4 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 50 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

752 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