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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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.
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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