Search with multiple parameters

  • Hello,

    I have a problem with searchcriteria.

    I have ASP.NET form with 3 textboxes where users can enter values for searching database.

    They can enter 1, 2 or 3 parameters to the stored procedure.

    My stored procedeure look like this. pseudo code

    create procedure test

    (

    @param1 nvarchar = null,

    @param2 nvarchar = null,

    @param3 nvarchar = null

    )

    as

    select value1, value2, value2 from testtable

    where

    (value1 LIKE ISNULL(@param1, value1) + '%' )AND

    (value2 LIKE ISNULL(@param2, value2) + '%') AND

    (value3 LIKE ISNULL(@param3, value3) + '%')

    This works great BUT if one column of the row is NULL the row wont return. Why?

  • WHERE(Value1 LIKE @Param1 + '%' OR @Param1 IS NULL)

    AND (Value2 LIKE @Param2 + '%' OR @Param2 IS NULL)

    AND (Value3 LIKE @Param3 + '%' OR @Param3 IS NULL)


    N 56°04'39.16"
    E 12°55'05.25"

  • works great!

    thanks alot

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply