• shilpaprele (10/8/2012)


    I have one procedure with parameter @P.

    If @p= null & table abc has many rows with col1 = null, then following select does not reurn the values

    select *

    from abc

    where col1 = @P

    what should be correct the syntax( do not wan tto use set ansi null on/off).

    select *

    from abc

    where col1 = @P

    OR (@P IS NULL AND col1 IS NULL)

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden