Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Correction to my last comment ...

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-26 : 09:53:49
Aaron writes "Sorry, I had a mistake in my query that I submitted to your guys a little bit ago which might have caused some confusion -- here is my revised question :

..................


I have wasted way too many hours trying to figure this one out
so I thought I'd throw it out there for the real experts.

Here is my question : How do you pass the arguments for a SQL
"in" clause as a parameter?

For instance, I have the following stored procedure :



CREATE PROCEDURE usp_FindMyState

@pState varchar(250)

AS

SELECT *
FROM statetable
WHERE state IN (@pState);



and I have a comma separated list of states (generated originally
from an HTML multiple listbox) that I want to pass in to the stored
proc. However, I am unable to get this to work using any of the
following combinations :

usp_FindMyState "CA,CO"
usp_FindMyState "'CA','CO'"

... even ...

usp_FindMyState 'CA"

... does not work ...


However, if I manually type in the exact code, it works fine such as :

SELECT *
FROM statetable
WHERE state IN ('CA','CO');


Oh, the agony. Help anyone?"
   

- Advertisement -