I have a stored procedure in SQL Server 2000 that performs a search based on parameter values. For one of the parameters passed in, I need a different WHERE cla
WHERE
WHERE MyColumn = COALESCE(@value,MyColumn)
If @value is NULL, it will compare MyColumn to itself, ignoring @value = no where clause.
@value
NULL
MyColumn
@value = no where
IF @value has a value (NOT NULL) it will compare MyColumn to @value.
NOT NULL
Reference: COALESCE (Transact-SQL).