Home Forums SQL Server 2005 Development Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. RE: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

  • I spotted that one, as well as "SET @LaborVal = (select b.LaborValue from Buffer b where b.BufferYear = datename(YY,getdate()))" later.

    These could be rewritten several ways. They all will execute without error, but the first two are equivalent to picking a random date. The last two give you control over which date is picked.

    SELECT @WeekStartDate = sdate FROM #tempFPRA

    SELECT TOP 1 @WeekStartDate = sdate FROM #tempFPRA

    SELECT @WeekStartDate = MIN(sdate) FROM #tempFPRA

    SELECT TOP 1 @WeekStartDate = sdate FROM #tempFPRA ORDER BY sdate