Solved

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

Posted on 2011-02-24
4
255 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 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associateā€¦
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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ā€¦
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

914 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