Marginalizing parameter

  • Thread starter Thread starter pamelafluente
  • Start date Start date
P

pamelafluente

In case I had a parametric query

SELECT Name, Phone from MyFriends WHERE MyFriends.city = @CITY

is it possible to specify a string value for @CITY in order to have
the query to behave exacly like :

SELECT Name, Phone from MyFriends ??

In other word, if this is possible, what is the parameter value which
would correspond to eliminate the WHERE condition ?

Or do I have necessary to remove the "where" part?

-P
 
Hi

If you use stored procedures, you could use the following code:

SELECT Name, Phone from MyFriends WHERE ((MyFriends.city = @CITY) or (@CITY IS NULL))

I don't know, if this works for you too.

Hope that helps
Greetings from Switzerland
Thomas


On 1 Oct 2006 01:14:57 -0700
 
Thomas Weingartner ha scritto:

Thanks Thomas

sounds like an interesting trick. I am going to try it!

Ciao,

-P
 
Back
Top