ALTER PROCEDURE [dbo].[HPMS_SelectDraftLOBReportByLOBId] (@LOBID nvarchar(20)=null ) As SET NOCOUNT ON; begin declare @err1 int begin transaction BEGIN Select * from DraftLOB where AssemblyId is not null and SessionId is not null and @LOBID IS NULL OR LOBId = @LOBID order by SrNo1, SrNo2, SrNo3 END