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

Re: Marginalizing parameter by Thomas

Thomas
Sun Oct 01 11:27:26 CDT 2006

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
pamelafluente@libero.it wrote:

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

Re: Marginalizing parameter by pamelafluente

pamelafluente
Sun Oct 01 12:25:19 CDT 2006

Thomas Weingartner ha scritto:

Thanks Thomas

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

Ciao,

-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
> pamelafluente@libero.it wrote:
>
> > 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
> >