Use a Column as Excel SQL Paramter

griffj

Board Regular
Joined
May 29, 2015
Messages
56
Hi,

Is it possible to use multiple values in a column as parameters for an Excel SQL query?

This is my current SQL statement, but when I try to enter the column as the parameter, it does not accept it.

Code:
SELECT Stock_Header.Part_Number, Stock_Header.Description, Stock_Locations.Sold_Last_Year/1000 AS 'Sold_Last_Year', Stock_Locations.Sold_This_Year/1000 AS 'Sold_This_Year'
FROM Dverto.dbo.Stock_Header Stock_Header, Dverto.dbo.Stock_Locations Stock_Locations
WHERE Stock_Header.Part_Number = Stock_Locations.Part_Number AND ((Stock_Locations.Stock_Location='SS') AND (Stock_Header.Part_Number=?))

Any help would be great.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
pass it as a variable, and loop through
or build an array from the column, and create an array to use as a selection statement
 
Upvote 0
Thanks for the response. Could you expand a little on the array. Know how to create an array not sure about the next step.
 
Upvote 0

Forum statistics

Threads
1,223,101
Messages
6,170,116
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top