i have the following code
DECLARE @ProjectID INT
DECLARE @getSLAPrjectID CURSOR
SET @getSLAPrjectID = CURSOR FOR SELECT ProjectID FROM SLA
OPEN @getSLAPrjectID
FETCH NEXT
FROM @getSLAPrjectID INTO @ProjectID
WHILE @@FETCH_STATUS = 0
BEGIN
BEGIN
SET @ScheduleVariance = (select case when (DATEDIFF(day,PlannedStartDate,PlannedEndDate)=0) THEN 0 ELSE (DATEDIFF(day,ActualStartDate,ActualEndDate)-DATEDIFF(day,PlannedStartDate,PlannedEndDate))/CAST(DATEDIFF(day,PlannedStartDate,PlannedEndDate) as float) END from SLA)
-- other piece of code that is working fine
END
FETCH NEXT
FROM @getSLAPrjectID INTO @ProjectID
END
CLOSE @getSLAPrjectID
DEALLOCATE @getSLAPrjectID
--end
I AM GETTING THE FOLLOWING ERROR : Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
please let me know if there is any alternative to either CASE statement in this piece of code or alternative to the scalar variable .