Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax for IN clause when used in Stored Procedure 1

Status
Not open for further replies.

forecasting

Programmer
May 2, 2002
130
0
0
I am trying to write a stored procedure where I can pass in the criteria as a single string. For example,

DECLARE @INclause nvarchar(20)
SET @INclause = '''WA'',''CA'''

SELECT City, State
FROM Atlas
WHERE State IN (@INclause)

SQL does not interpret the @INclause as two criteria. Does anybody know how to do this?
 
Take a look at this thread (thread183-1232415). It's very similar to what you are asking.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I think what you are saying is to insert the values into a temporary table in order to use them. Am I correct?
 
Yes. The User Defined Function that I show in the other thread makes it easy to do that. It's relatively generic so it will probably work in most cases. Preformance may be an issue if the 'comma delimited list' is large.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Alas! I was hoping for something easier. Sooner or later, every good idea degenerates into work.

Thanks for the answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top