Home Forums SQL Server 2008 SQL Server Newbies Dynamic WHERE statement if stored procedure parameter is null RE: Dynamic WHERE statement if stored procedure parameter is null

  • I use this syntax in my where clauses rather than case statements:

    WHERE

    ((@StartDate IS NOT NULL AND StartDate >= @StartDate)

    OR

    (@StartDate IS NULL))

    AND ((@EndDate IS NOT NULL AND EndDate <= @EndDate)

    OR

    (@EndDate IS NULL))