[dba-SQLServer] Stored Procedure SQL IN Clause

Robert L. Stewart rl_stewart at highstream.net
Mon Feb 16 10:15:48 CST 2004


All,

The end of last week, I was working on a stored procedure in SQL Server.  I 
wanted it to be able to pass in information via a parameter to populate an 
IN clause in the SQL statement so I could use a multi-select list box for 
the control on the form.

Here is what I was trying:

I have a list of residence types (house, hotel, mobile home, homeless, 
etc.).  I wanted to be able to select one or more in the list box.

The Stored Procedure looked something like this:

CREATE PROCEDURE uspResidenceTypeList
@InClause Varchar(200)
AS
SELECT *
FROM tblClient
WHERE (ResidenceType IN(@InClause)

This works for a single value, i.e. 'Homeless', but it returns no records 
when I pass in multiple values.

Does someone have any ideas about what I can do to get this to work?

Thanks,

Robert

Note Cross posted to dba-sqlserver at databaseadvisors.com





More information about the dba-SQLServer mailing list