Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-24
4
Medium Priority
?
261 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 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

730 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