Re: Performance using coalesce()

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Zach Wells (no_zwells_spam_at_ain1.com)
Date: 04/23/04


Date: Fri, 23 Apr 2004 10:52:44 -0400

Jacco Schalkwijk wrote:

> The code you are looking for probably is:
>
> SELECT * FROM sometable
> WHERE @someparameter IS NULL OR @someparameter = someColumn
>
> Note that I use a (stored procedure) parameter, not a variable. Using
> variables ususally prevents the query optimizer from generating the optimal
> execution plan.
>

That's it, thanks! And, I really did mean a parameter, not a variable.

Zach



Relevant Pages

  • Re: Problems using a Table Variable
    ... Persson" wrote in message ... >>>>UPDATE @TaskOrg t>>..... ... >>>>should work>>>>-->>Jacco Schalkwijk>>SQL Server MVP>> ... >>> In our system I have discovered that a stored procedure,>>> changed by some of my ...
    (microsoft.public.sqlserver.programming)
  • Re: I have a problem with an article I want to be published under two categories.
    ... You can just call the stored procedure twice, once for each category if you ... > "Jacco Schalkwijk" wrote in message ... The Primary key on this table is a composite ... >> SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Query about the LIKE statement
    ... Step2: ... In my stored procedure, ... select (blah blah many cases and all that for cross tab reports) ... >> Jacco Schalkwijk ...
    (microsoft.public.sqlserver.programming)
  • Re: Help In Stored Procedure
    ... Jacco Schalkwijk ... SQL Server MVP ... this in stored procedure or through query also. ... > If anybody know any other method or a better procedure plz help ...
    (microsoft.public.sqlserver.server)