ALTER PROCEDURE [dbo].[PDSCMBSPURCHASEDOCSTATUS] ( @DocType VARCHAR(20) ,@MenuID VARCHAR(250) ) AS --DECLARE @DocType VARCHAR(20) = '' --DECLARE @MenuID VARCHAR(250) = '' IF(@MenuID = 'PURCHREQUISITIONDRAFT') BEGIN SELECT * FROM dbo.PCMBSPURCHASEDOCSTATUS WHERE DocStatus IN ('1','3','5') AND DocType = @DocType END ELSE IF(@MenuID = 'PURCHDEMANDFORGOODS') BEGIN SELECT * FROM dbo.PCMBSPURCHASEDOCSTATUS WHERE DocStatus IN ('2') AND DocType = @DocType END ELSE IF(@MenuID = 'PURCHREQUISITION') BEGIN SELECT * FROM dbo.PCMBSPURCHASEDOCSTATUS WHERE DocType = @DocType END ELSE IF(@MenuID = 'PURCHORDER') BEGIN SELECT * FROM dbo.PCMBSPURCHASEDOCSTATUS WHERE DocType = 'PO' END ELSE BEGIN SELECT DISTINCT StartDate, EndDate, '', DocStatus, Description FROM dbo.PCMBSPURCHASEDOCSTATUS END