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
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,511
Messages
5,596,581
Members
414,079
Latest member
Frills

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