One thing you can do is ...
create procedure myProc
(@status char(1))
AS
BEGIN
set nocount on;
IF (@status ='B')
BEGIN
/* run this code with no filtering by the field 'active'*/
END
ELSE
BEGIN
SELECT /* your columns
..., etc... */
WHERE active = @status
END
END/* proc */
I have a hunch the engine can produce multiple query plans in this instance. Is this correct?
----------------------------------------------------