passing a parameter for an 'IN' clause

passing a parameter for an 'IN' clause

Post by Tim Norri » Tue, 22 Jun 1999 04:00:00



I've got a sp that has a variable number of parameters that I want to pass
as part of an in clause.

This works:
select * from county where county.state_name in 'VT', 'NH','NY'

Since the number of states passed is variable I need to pass a string so the
sp looks like this:

The single quotes needed crash the sp.

Any ideas, suggestions?
Thanks,
Tim

 
 
 

passing a parameter for an 'IN' clause

Post by Buddy Ackerma » Tue, 22 Jun 1999 04:00:00


Define you variable like this:


Anywhere you want a literal quote in a string variable you need to use two
single quotes together.

--Buddy


> I've got a sp that has a variable number of parameters that I want to pass
> as part of an in clause.

> This works:
> select * from county where county.state_name in 'VT', 'NH','NY'

> Since the number of states passed is variable I need to pass a string so
the
> sp looks like this:

> The single quotes needed crash the sp.

> Any ideas, suggestions?
> Thanks,
> Tim


 
 
 

passing a parameter for an 'IN' clause

Post by Meade Robbo » Tue, 22 Jun 1999 04:00:00


Tim,


')')

-Meade


> I've got a sp that has a variable number of parameters that I want to pass
> as part of an in clause.

> This works:
> select * from county where county.state_name in 'VT', 'NH','NY'

> Since the number of states passed is variable I need to pass a string so
the
> sp looks like this:

> The single quotes needed crash the sp.

> Any ideas, suggestions?
> Thanks,
> Tim