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)
 A challenge : passing arguments into SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-20 : 10:01:16
Aaron Christy writes "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

@a3_State 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 -