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