select A.RegistrationId,B.CustomerName,ServiceNo as ServiceNo,convert(varchar(20),OrderDate,110) OrderDate,
D.ProductName,E.ServiceName,convert(varchar(20),C. DeliveryDate,110) DeliveryDate
from TBL_ServiceRegistration A
left OUTER JOIN TBL_CustomerMaster B on A.CustomerId=B.CustomerId
left outer JOIN TBL_ServiceRegistration_Details C on A.RegistrationId=C.RegistrationId
left outer JOIN TBL_ProductMaster D ON C.ProductId=D.ProductId
left OUTER JOIN TBL_ServiceEntry E on C.ServiceId=E.ServiceId
where (@ServiceId=0 OR A.RegistrationId=@ServiceId) and (@CustomerId=0 OR A.CustomerId=@CustomerId)