Imbedded SQL query with a "list" for a parameter

Big Freak CC

New Member
Joined
Feb 11, 2004
Messages
2
I am trying to write a SQL query in Excel which needs two inputs taken in as parameters. One is just a date, which is easy and works. The second requires a list of names that will change every day.

So ordinarily, the query would read

blah blah blah
where name in ('Jon','Eric','Connie','Phil'....)

But when you set up the name list as a paramter (which has to be only a single cell), I can't get it to work. No matter what I try this error comes up:

[Microsoft][ODBC SQL Server Driver]String Data, right truncation

How can I fix this.

Thanks

Jon
 

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.

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Re: Imbedded SQL query with a "list" for a paramet

In the absence of another reply ..........
I am no SQL expert, but if I needed something like this I would set up the name list as a separate table and do a JOIN query with the main table. I would probably do the job in MS Access anyway, but if you set up a query in Access it writes a SQL string, which can then be copied/pasted elsewhere from View/SQL.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,960
Messages
5,856,525
Members
431,820
Latest member
Tori Murphy

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
Top