ALTER PROCEDURE [dbo].[PDSCMBSLOGDOCSTATUS] ( @DocType VARCHAR(20) ,@MenuID VARCHAR(250) ) AS --DECLARE @DocType VARCHAR(20) = 'RCSP' --DECLARE @MenuID VARCHAR(250) = 'RCSP' IF(@MenuID = 'GICU2') BEGIN SELECT * FROM dbo.PCMBSLOGDOCSTATUS WHERE DocStatus IN ('1','4') END IF(@MenuID = 'GICU') BEGIN SELECT * FROM dbo.PCMBSLOGDOCSTATUS WHERE DocType = @DocType END IF(@MenuID = 'RCSP') BEGIN SELECT * FROM dbo.PCMBSLOGDOCSTATUS WHERE DocType = @DocType END IF(@DocType = 'MTPR') BEGIN SELECT * FROM dbo.PCMBSLOGDOCSTATUS WHERE DocType = @DocType END IF(@DocType = 'RTCU') BEGIN SELECT * FROM dbo.PCMBSLOGDOCSTATUS WHERE DocType = @DocType END IF(@DocType = 'RTSP') BEGIN SELECT * FROM dbo.PCMBSLOGDOCSTATUS WHERE DocType = @DocType END ELSE BEGIN SELECT * FROM dbo.PCMBSLOGDOCSTATUS --WHERE DocType = @DocType END