We help IT Professionals succeed at work.
Get Started

Using a Cell Reference in a SQL Query

CiciO
CiciO asked
on
11,648 Views
Last Modified: 2011-10-02
I can't believe this is so hard.  I think I've seen 100 answers on EE to this exact question and I still can't figure it out.

I have a SQL Server database with a table called Branches.  I want to type a branch number into cell B7 of my spreadsheet and have Excel go out to SQL Server and get all of the information for the specified branch.

In Excel I went to Data > Import External Data > New Databse Query
I found the table.
I was able to create the following SQl... select * from "Autopart"."dbo"."Branches" where branch = '2024'

The problem is that I had to hard code the value 2024 when I really want it to look at cell B7 and use whatever value it finds.

I know nothing about VBA or ADO.

From everything I've read it seems quite doable, I just can't figure it out.

Does anybody have any "dummy" level instructions that might help me?

...timmy
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE