Hello,
Have you tried rewriting your proc as shown below.
ALTER PROCEDURE [dbo].[sp_GatherCenterInfoForSpecialpaymentsTypes]
(
@company_u_id int,
@UnitId int
)
AS
BEGIN
SET NOCOUNT ON;
SELECT t1.Center_Name, t1.Center_Code, t1.Center_Id, t1.Center_Id_Format
FROM DayOpenDayCloseInfo
INNER JOIN (
(SELECT CenterInfo.Center_Name, CenterInfo.Center_Code,
CenterInfo.Center_Id,CenterInfo.Center_Id_Format,
MAX(DayOpenDayCloseInfo.DayOPenCloseId) AS DayOPenCloseId
FROM CenterInfo
INNER JOIN DayOpenDayCloseInfo
ON CenterInfo.Center_Id = DayOpenDayCloseInfo.Center_Id
WHERE (CenterInfo.Unit_Id = @UnitId) AND (CenterInfo.IsActive = 1)
AND (CenterInfo.company_u_id=@company_u_id)
GROUP BY CenterInfo.Center_Name, CenterInfo.Center_Code,
CenterInfo.Center_Id, CenterInfo.Center_Id_Format)
) t1
ON t1.Center_Id = DayOpenDayCloseInfo.Center_Id
WHERE DayOpenDayCloseInfo.IsActive = 0
END
RETURN
Regards,