WHERE StatusId != 3 AND (@ServiceId IS NULL OR ServiceId=@ServiceId) AND (PersonId IS NULL OR PersonId=@PersonId)
AND (PersonId IS NULL OR PersonId=@PersonId)
AND (@PersonId IS NULL OR PersonId=@PersonId)
DECLARE @sql VARCHAR(MAX) SET @sql = 'SELECT <FieldList> FROM TableName WHERE StatusId !=3' IF (@ServiceId IS NULL) SET @sql = @sql + ' AND ServiceId=' + @ServiceId IF (@PersonId IS NULL) SET @sql = @sql + ' AND PersonId=' + @PersonId EXEC(@sql)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)