best way to: where [field] = @field --with set ansi_nulls on

  • when using:

    set ansi_nulls on

    what is the best way to filter using parameters and allow for nulls:

    this will not work properly:

    select *

    from

    where [field] = @field

    is there a better way than this?

    select *

    from

    where (([field] is null and @field is null) or ([field] = @field))

  • Nope, nothing better. NULLs must be checked separately.

    Scott Pletcher, SQL Server MVP 2008-2010

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

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